{"record":{"id":"cc61cc3a452362c8","repo":"hashicorp/terraform","slug":"retrieving-container-client-v","errorCode":null,"errorMessage":"retrieving container client: %v","messagePattern":"retrieving container client: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/remote-state/azure/backend_state.go","lineNumber":37,"sourceCode":")\n\nconst (\n\t// This will be used as directory name, the odd looking colon is simply to\n\t// reduce the chance of name conflicts with existing objects.\n\tkeyEnvPrefix = \"env:\"\n)\n\nfunc (b *Backend) Workspaces() ([]string, tfdiags.Diagnostics) {\n\tvar diags tfdiags.Diagnostics\n\tprefix := b.keyName + keyEnvPrefix\n\tparams := containers.ListBlobsInput{\n\t\tPrefix: &prefix,\n\t}\n\n\tctx := newCtx()\n\tclient, err := b.apiClient.getContainersClient(ctx)\n\tif err != nil {\n\t\treturn nil, diags.Append(fmt.Errorf(\"retrieving container client: %v\", err))\n\t}\n\tresp, err := client.ListBlobs(ctx, b.containerName, params)\n\tif err != nil {\n\t\treturn nil, diags.Append(fmt.Errorf(\"listing blobs: %v\", err))\n\t}\n\n\tenvs := map[string]struct{}{}\n\tfor _, obj := range resp.Blobs.Blobs {\n\t\tkey := obj.Name\n\t\tif strings.HasPrefix(key, prefix) {\n\t\t\tname := strings.TrimPrefix(key, prefix)\n\t\t\t// we store the state in a key, not a directory\n\t\t\tif strings.Contains(name, \"/\") {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tenvs[name] = struct{}{}\n\t\t}","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/backend/remote-state/azure/backend_state.go#L19-L55","documentation":"Wrapping error from Workspaces() when b.apiClient.getContainersClient(ctx) fails on first use. Propagates any of the underlying container-client construction errors (145, 146, 147, 148, or invalid base-URI).","triggerScenarios":"Any code path that lists workspaces (`terraform workspace list`, `terraform workspace select`, internal init enumeration) triggers the lazy container-client build; if that build fails, this wraps it.","commonSituations":"Workspace listing right after a misconfigured `terraform init`; auth expired between init and the workspace command; transient network failure.","solutions":["Inspect the wrapped %v to identify which container-client error fired (145-148).","Fix the underlying cause (URL / RBAC / key / AAD).","Re-run `terraform init -reconfigure` then the workspace command."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// When listing workspaces, surface the underlying error verbosely.\nws, diags := backend.Workspaces()\nif diags.HasErrors() {\n    for _, d := range diags {\n        if strings.Contains(d.Description().Summary, \"retrieving container client\") {\n            // log the inner error and run pre-flight checks for 145-148\n        }\n    }\n}","preventionTips":["Resolve container-client errors (145-148) at init time before invoking workspace commands.","Re-init with `terraform init -reconfigure` after auth changes.","In CI, run `terraform workspace list` as a smoke test before plan/apply."],"tags":["azure","container","workspace","terraform-backend","wrapper"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}