Resolution
Make sure the account your built-in step uses is allowed in the environment and tenant (if applicable) you're deploying to. Either widen the account's Restrictions/Scope in the account settings so they include that environment and tenant, or change the account variable's scope so it resolves to an account that's already allowed there. If you changed project variables, create a new release or update the release's variable snapshot, then re-run the deployment preview.
Symptom
A built-in step that uses an account, such as Run an Azure Script, Run an AWS CLI Script, or Deploy to Kubernetes, fails during the deployment preview or when the deployment starts. The error says the account can't be found, even though the account exists and Variables ➜ Preview shows the account variable resolving to it.
Could not find account with ID '<account-id>', which is the value of variable '<variable-name>'.
The wording can differ slightly between step types and Octopus versions. The common pattern is a "can't find" message that names an account ID or the account variable.
Scope: when this is the right article
This article applies when all of these are true:
- The step is a built-in step that takes an account, either through an account variable or by selecting the account directly.
- The account exists in the same space as the project. You can open it in Infrastructure ➜ Accounts.
- Variables ➜ Preview for the same environment (and tenant, if you use one) shows the variable resolving to that account.
- The account has Restrictions/Scope configured: specific environments, a tenanted deployment mode, or specific tenants or tenant tags.
This article doesn't apply if:
- The account was deleted, or it lives in a different space. That's a genuine "not found".
- The step authenticates successfully, but the cloud provider rejects the request. That's normally a permissions problem in Azure, AWS, or Google Cloud, rather than configuration in Octopus.
Cause
Two separate checks decide which account a built-in step can use, and Variables Preview only shows you one of them.
- Variable scoping. Octopus picks the account variable value that best matches the deployment's environment, channel, tenant, target tags, and step. Variables Preview evaluates this check, so the variable looks correct there.
- Account restrictions/scoping. When a built-in step resolves the account in deployment context, Octopus also checks the account's own Restrictions/Scope configuration against the deployment: the environment being deployed to, whether the deployment is tenanted, and which tenant it's for. Variables Preview doesn't apply this check.
If the variable resolves to an account whose restrictions don't include the deployment's environment or tenant, the account isn't authorized for that deployment. Octopus treats an account the deployment isn't allowed to use as unavailable, so the error reports that the account can't be found rather than that it's not authorized.
Common ways this mismatch appears:
- The account is restricted to
Production, but the variable value pointing to it is unscoped or scoped to a broader set of environments, so it also resolves forStaging. - The account is set to Exclude from tenanted deployments, and the project now deploys tenanted.
- The account is restricted to specific tenants or tenant tags, and the tenant being deployed doesn't match them.
- An environment was added to the project's lifecycle or channel, but nobody added it to the account's restrictions/scoping.
Diagnosis and fix
These checks only read configuration until the final step. You need permission to view the project, its variables, and the account.
Inspect the account configuration
-
Record the deployment context. From the failed deployment or deployment preview, write down the project, channel, environment, and tenant (if any). Copy the account ID and the variable name from the error message.
-
Confirm the account exists in this space. Go to Infrastructure ➜ Accounts in the project's space, then open the account. To find it by ID, open each candidate account and check the ID at the end of the browser URL. If the account isn't there, it was deleted or belongs to a different space, and this article doesn't apply.
-
Check the account's restrictions/scoping. On the account page, look at the Restrictions/Scope section:
-
Environments: Is the deployment's environment listed? An empty list means all environments are allowed.
- Tenanted deployments: If the deployment is tenanted, the account must be set to Include only in tenanted deployments or Include in both tenanted and untenanted deployments. If the deployment is untenanted, the account must not be set to tenanted only.
- Tenants and tenant tags: For a tenanted deployment, is the tenant listed, or does it have one of the listed tenant tags?
If any of these doesn't match the deployment context from step 1, you've found the authorization mismatch.
-
Check the project, lifecycle, and channel. Open the project and check which channel the release belongs to and which lifecycle that channel uses. Make sure every environment in that lifecycle that the step runs in is also allowed by the account's restrictions. Check whether the project is tenanted (in Project Settings, under Multi-tenanted deployments), because that determines whether the account's tenanted deployment setting applies.
-
Check the tenant. If the deployment is tenanted, go to Tenants, open the tenant, and confirm it's connected to this project and environment. Check its tenant tags against the account's tenant tag restrictions. A tag the account expects may be missing from the tenant.
-
Check the variable scope. In the project's Variables (and any included variable sets or tenant variables), find every value of the account variable named in the error. For each value, compare its scope with the restrictions of the account it points to. Look for a value whose scope is broader than its account's restrictions, such as an unscoped value that points to a production-only account.
Fix the account configuration
Choose the option that matches your scenario:
- If the account should be used in this environment or for this tenant, edit the account's Restrictions/Scope to include that environment, tenanted deployment mode, tenant, or tenant tag, and save.
- If a different account should be used here, edit the account variable so this environment or tenant resolves to the right account. Add a value scoped to this environment or tenant, or narrow the existing value's scope to match its account's restrictions.
- If the step selects an account directly rather than through a variable, switch it to an account variable scoped per environment, or pick an account whose restrictions cover every environment and tenant the step runs in.
Create a new release/update the variable snapshot
A release retains a snapshot of the project's variables, so variable changes don't propagate to existing releases. If you changed any project variables, the release will need to be refreshed. You can do this by creating a new release or by opening the existing release and selecting Update variables. Changes to the account's restrictions and to tenant variables don't need a new release.
Verify
- Open Variables ➜ Preview and select the same environment, channel, and tenant (if applicable) as the failed deployment. Confirm the account variable resolves to the account you expect.
- Open that account in Infrastructure ➜ Accounts and confirm its Restrictions/Scope include that environment and tenant.
- Start a deployment of the release to the same environment and tenant. The deployment preview should load without the account error.
- Run the deployment and confirm the built-in step authenticates and completes. The task log shows the step using the account you expect.
If you deploy to multiple environments or tenants, repeat the preview for each. A fix for one environment can still leave another mismatched.
Related
- Azure accounts: how to create Azure accounts and restrict them to environments, tenants, and tenant tags
- Accounts overview: the account types Octopus supports
- Azure account variables: how to reference an Azure account from a project variable
- AWS account variables: how to reference an AWS account from a project variable
- Google Cloud account variables: how to reference a Google Cloud account from a project variable
- Getting started with variables: how variable scoping works and how Octopus picks a value
- Tenant infrastructure: how tenanted deployment participation works for infrastructure