hashicorp/terraform · error
building Storage Accounts client: %+v
Error message
building Storage Accounts client: %+v
What it means
Returned by buildClient when storageaccounts.NewStorageAccountsClientWithBaseURI fails for the configured Azure environment's ResourceManager endpoint. This is a low-level SDK client construction failure, typically because the environment's ResourceManager base URI is invalid or the SDK cannot initialize against it.
Source
Thrown at internal/backend/remote-state/azure/api_client.go:98
}
// When using Azure CLI to auth, the user can leave the "subscription_id" unspecified. In this case the subscription id is inferred from
// the Azure CLI default subscription.
if config.SubscriptionID == "" {
if cachedAuth, ok := resourceManagerAuth.(*auth.CachedAuthorizer); ok {
if cliAuth, ok := cachedAuth.Source.(*auth.AzureCliAuthorizer); ok && cliAuth.DefaultSubscriptionID != "" {
config.SubscriptionID = cliAuth.DefaultSubscriptionID
}
}
}
if config.SubscriptionID == "" {
return nil, fmt.Errorf("subscription id not specified")
}
// Setup the SA client.
client.storageAccountsClient, err = storageaccounts.NewStorageAccountsClientWithBaseURI(config.AuthConfig.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Storage Accounts client: %+v", err)
}
client.configureClient(client.storageAccountsClient.Client, resourceManagerAuth)
// Populating the storage account detail
storageAccountId := commonids.NewStorageAccountID(config.SubscriptionID, config.ResourceGroupName, client.storageAccountName)
resp, err := client.storageAccountsClient.GetProperties(ctx, storageAccountId, storageaccounts.DefaultGetPropertiesOperationOptions())
if err != nil {
return nil, fmt.Errorf("retrieving %s: %+v", storageAccountId, err)
}
if resp.Model == nil {
return nil, fmt.Errorf("retrieving %s: model was nil", storageAccountId)
}
client.accountDetail, err = populateAccountDetails(storageAccountId, *resp.Model)
if err != nil {
return nil, fmt.Errorf("populating details for %s: %+v", storageAccountId, err)
}
}
View on GitHub (pinned to c9def3e214)
Solutions
- Verify environment_name / ARM_ENVIRONMENT points to a valid, complete Azure environment definition.
- For airgapped/custom clouds, ensure the environment metadata's ResourceManager endpoint is a valid absolute URL.
- Switch to a well-known environment (public, usgovernment, china) if a custom one is misconfigured.
Defensive patterns
Strategy: validation
Validate before calling
// Validate the environment metadata before building the client.
if config.AuthConfig.Environment.ResourceManager == (environments.Api{}) {
return errors.New("environment has no ResourceManager endpoint; check environment_name")
} Prevention
- Use a known environment_name (public, usgovernment, china) unless a custom cloud is verified.
- For custom clouds, validate all endpoints (ResourceManager, Storage) are populated and absolute.
- Test backend init against the target environment in a staging subscription first.
When it happens
Trigger: ARM auth succeeded but constructing the Storage Accounts management client with the environment's ResourceManager base URI errors. Triggered during terraform init when the backend needs the ARM storage client (to look up the blob endpoint or list keys).
Common situations: Custom/airgapped cloud environment with a malformed ResourceManager endpoint; misconfigured environment_name pointing at an environment whose metadata is incomplete; SDK version incompatibility parsing the endpoint URL.
Related errors
- unable to build authorizer for Resource Manager API: %+v
- retrieving %s: %+v
- retrieving %s: model was nil
- new blob client: %v
- sasToken cannot be empty
AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07).
Data as JSON: /api/errors/a27b58db62a25b0f.
Report an issue: GitHub.