hashicorp/terraform · error

retrieving %s: %+v

Error message

retrieving %s: %+v

What it means

Returned by buildClient when client.storageAccountsClient.GetProperties fails to retrieve the Storage Account via the ARM API. The %s is the full resource ID (subscription/resource-group/account) and %+v is the ARM error. This is the actual remote GET against the storage account resource.

Source

Thrown at internal/backend/remote-state/azure/api_client.go:106

				}
			}
		}
		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)
		}
	}

	return &client, nil
}

func (c *Client) getBlobClient(ctx context.Context) (bc *blobs.Client, err error) {
	if c.blobsClient != nil {
		return c.blobsClient, nil
	}

View on GitHub (pinned to c9def3e214)

Solutions

  1. Verify storage_account_name and resource_group_name are correct and the account exists in the subscription.
  2. Grant the service principal 'Reader' (or Storage Account Contributor) on the storage account/resource group.
  3. Retry on transient/network errors; check Azure status for outages.
Defensive patterns

Strategy: retry

Validate before calling

// Confirm the account exists and is readable before init.
// (Run 'az storage account show -g <rg> -n <acct>' as a pre-flight check.)

Try / catch

client, err := buildClient(ctx, config)
if err != nil && strings.Contains(err.Error(), "retrieving") {
    // likely wrong name/rg/RBAC; verify names and permissions
}

Prevention

When it happens

Trigger: ARM auth and client construction succeeded, but the GetProperties call for the storage account fails — account doesn't exist, wrong resource group, RBAC denies the read, throttled, or transient network failure. Triggered during terraform init when lookup_blob_endpoint is needed.

Common situations: Typo in storage_account_name or resource_group_name; the principal has no 'Reader' access to the storage account; subscription mismatch; account deleted; ARM throttling; transient outage.

Related errors


AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07). Data as JSON: /api/errors/241acdadeb158434. Report an issue: GitHub.