{"record":{"id":"db4b307d221d0188","repo":"VictoriaMetrics/VictoriaMetrics","slug":"missing-azure-storage-account-name-environment-var-db4b30","errorCode":null,"errorMessage":"missing AZURE_STORAGE_ACCOUNT_NAME environment variable when AZURE_USE_DEFAULT_CREDENTIAL=true is set; see https://docs.victoriametrics.com/victoriametrics/vmbackup/#providing-credentials-via-env-variables","messagePattern":"missing AZURE_STORAGE_ACCOUNT_NAME environment variable when AZURE_USE_DEFAULT_CREDENTIAL=true is set; see https://docs\\.victoriametrics\\.com/victoriametrics/vmbackup/#providing-credentials-via-env-variables","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/backup/azremote/azblob.go","lineNumber":114,"sourceCode":"\t\tcreds, err := azblob.NewSharedKeyCredential(accountName, accountKey)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to create Shared Key credentials: %w\", err)\n\t\t}\n\t\tserviceURL := fs.getServiceURL(accountName)\n\t\treturn service.NewClientWithSharedKeyCredential(serviceURL, creds, nil)\n\t}\n\n\tuseDefault := fs.env(\"AZURE_USE_DEFAULT_CREDENTIAL\")\n\tif useDefault == \"true\" {\n\t\tlogger.Infof(\"creating AZBlob service client from default credentials\")\n\t\tcreds, err := azidentity.NewDefaultAzureCredential(nil)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to create default Azure credentials: %w\", err)\n\t\t}\n\n\t\taccountName := fs.env(\"AZURE_STORAGE_ACCOUNT_NAME\")\n\t\tif accountName == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"missing AZURE_STORAGE_ACCOUNT_NAME environment variable when AZURE_USE_DEFAULT_CREDENTIAL=true is set; \" +\n\t\t\t\t\"see https://docs.victoriametrics.com/victoriametrics/vmbackup/#providing-credentials-via-env-variables\")\n\t\t}\n\n\t\tserviceURL := fs.getServiceURL(accountName)\n\t\treturn service.NewClient(serviceURL, creds, nil)\n\t}\n\n\treturn nil, fmt.Errorf(\"failed to detect credentials for AZBlob; ensure that one of the options listed at \" +\n\t\t\"https://docs.victoriametrics.com/victoriametrics/vmbackup/#providing-credentials-via-env-variables is set\")\n}\n\nfunc (fs *FS) env(name string) string {\n\tif fs.envLookupFunc != nil {\n\t\tv, _ := fs.envLookupFunc(name)\n\t\treturn v\n\t}\n\tv, _ := envtemplate.LookupEnv(name)\n\treturn v","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/VictoriaMetrics/VictoriaMetrics/blob/5079fb58f1e8e62113f90c945ad71586c797d770/lib/backup/azremote/azblob.go#L96-L132","documentation":"Raised by azremote/azblob.go newClient() when AZURE_USE_DEFAULT_CREDENTIAL=true is set but AZURE_STORAGE_ACCOUNT_NAME is empty. Default Azure credentials authenticate the caller, but the client still needs the storage account name to build the service URL (https://<account>.<domain>/). The library refuses to guess the account, so FS.Init() fails and no backup can proceed.","triggerScenarios":"AZURE_USE_DEFAULT_CREDENTIAL=true exported, but AZURE_STORAGE_ACCOUNT_NAME missing, empty after envtemplate expansion (e.g. it references an unset ${VAR} placeholder), or set only in a shell/profile that the backup process does not inherit (systemd unit, container, cron).","commonSituations":"Containerized vmbackup where env vars were defined in the host shell but not passed into the container; systemd services with a stale EnvironmentFile; mis-typed variable name (e.g. AZURE_STORAGE_ACCOUNT instead of AZURE_STORAGE_ACCOUNT_NAME); config template expanding to empty string.","solutions":["Set AZURE_STORAGE_ACCOUNT_NAME to the storage account that hosts the backup container before starting the backup.","If using envtemplate syntax, verify the referenced variable (e.g. ${AZURE_STORAGE_ACCOUNT_NAME}) is actually populated in the process environment.","Check the process environment the backup runs with (systemd EnvironmentFile=, docker -e / k8s env) — not just the interactive shell.","Alternatively switch to AZURE_STORAGE_ACCOUNT_CONNECTION_STRING, which embeds both account name and key."],"exampleFix":"// before\nAZURE_USE_DEFAULT_CREDENTIAL=true   # account name missing\n\n// after\nexport AZURE_USE_DEFAULT_CREDENTIAL=true\nexport AZURE_STORAGE_ACCOUNT_NAME=mystorageacct","handlingStrategy":"validation","validationCode":"if os.Getenv(\"AZURE_USE_DEFAULT_CREDENTIAL\") == \"true\" && os.Getenv(\"AZURE_STORAGE_ACCOUNT_NAME\") == \"\" {\n\treturn errors.New(\"AZURE_STORAGE_ACCOUNT_NAME must be set when AZURE_USE_DEFAULT_CREDENTIAL=true\")\n}","typeGuard":null,"tryCatchPattern":"if err := fs.Init(ctx); err != nil {\n\tif strings.Contains(err.Error(), \"AZURE_STORAGE_ACCOUNT_NAME\") {\n\t\treturn fmt.Errorf(\"config: %w (set AZURE_STORAGE_ACCOUNT_NAME in the service environment)\", err)\n\t}\n\treturn err\n}","preventionTips":["Always set AZURE_STORAGE_ACCOUNT_NAME alongside AZURE_USE_DEFAULT_CREDENTIAL=true in the same environment (container spec, systemd EnvironmentFile).","Validate required env vars at deploy time (helm/terraform/compose config checks).","Beware envtemplate ${VAR} placeholders expanding to empty strings.","Name variables exactly: AZURE_STORAGE_ACCOUNT_NAME, not AZURE_STORAGE_ACCOUNT."],"tags":["azure","env-config","missing-env-var","backup"],"backgroundTag":"missing-env-var","analyzedSha":"5079fb58f1e8e62113f90c945ad71586c797d770","analyzedAt":"2026-09-03T18:10:26.153Z","contentChangedAt":"2026-09-03T18:10:26.153Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}