VictoriaMetrics/VictoriaMetrics · error

missing AZURE_STORAGE_ACCOUNT_NAME environment variable when

Error message

missing AZURE_STORAGE_ACCOUNT_NAME environment variable when AZURE_STORAGE_ACCOUNT_KEY is set; see https://docs.victoriametrics.com/victoriametrics/vmbackup/#providing-credentials-via-env-variables

What it means

When newClient sees AZURE_STORAGE_ACCOUNT_KEY set, it requires AZURE_STORAGE_ACCOUNT_NAME too, since SharedKey auth needs both. If the name is missing it returns this explicit error with a link to the vmbackup docs on env-var credentials. It is a configuration validation error, not a network one.

Source

Thrown at lib/backup/azremote/azblob.go:93

	fs.metadata = meta

	return nil
}

func (fs *FS) newClient() (*service.Client, error) {
	connString := fs.env("AZURE_STORAGE_ACCOUNT_CONNECTION_STRING")
	if connString != "" {
		logger.Infof("creating AZBlob service client from connection string defined at AZURE_STORAGE_ACCOUNT_CONNECTION_STRING")
		return service.NewClientFromConnectionString(connString, nil)
	}

	accountKey := fs.env("AZURE_STORAGE_ACCOUNT_KEY")
	if accountKey != "" {
		logger.Infof("creating AZBlob service client from account name and key")

		accountName := fs.env("AZURE_STORAGE_ACCOUNT_NAME")
		if accountName == "" {
			return nil, fmt.Errorf("missing AZURE_STORAGE_ACCOUNT_NAME environment variable when AZURE_STORAGE_ACCOUNT_KEY is set; " +
				"see https://docs.victoriametrics.com/victoriametrics/vmbackup/#providing-credentials-via-env-variables")
		}
		creds, err := azblob.NewSharedKeyCredential(accountName, accountKey)
		if err != nil {
			return nil, fmt.Errorf("failed to create Shared Key credentials: %w", err)
		}
		serviceURL := fs.getServiceURL(accountName)
		return service.NewClientWithSharedKeyCredential(serviceURL, creds, nil)
	}

	useDefault := fs.env("AZURE_USE_DEFAULT_CREDENTIAL")
	if useDefault == "true" {
		logger.Infof("creating AZBlob service client from default credentials")
		creds, err := azidentity.NewDefaultAzureCredential(nil)
		if err != nil {
			return nil, fmt.Errorf("failed to create default Azure credentials: %w", err)
		}

View on GitHub (pinned to 5079fb58f1)

Solutions

  1. Export AZURE_STORAGE_ACCOUNT_NAME alongside AZURE_STORAGE_ACCOUNT_KEY
  2. Verify with `env | grep AZURE_STORAGE` that both variables are visible to the vmbackup process
  3. In CI, add the account name to the secret/env configuration of the job
  4. Alternatively unset the key and use AZURE_USE_DEFAULT_CREDENTIAL with a managed identity or az login

Example fix

// before (shell/CI env)
export AZURE_STORAGE_ACCOUNT_KEY=xxxx
// after
export AZURE_STORAGE_ACCOUNT_NAME=mystorageacct
export AZURE_STORAGE_ACCOUNT_KEY=xxxx
Defensive patterns

Strategy: validation

Validate before calling

func requireAzureKeyPair() error {
	if os.Getenv("AZURE_STORAGE_ACCOUNT_KEY") != "" && os.Getenv("AZURE_STORAGE_ACCOUNT_NAME") == "" {
		return fmt.Errorf("set AZURE_STORAGE_ACCOUNT_NAME when AZURE_STORAGE_ACCOUNT_KEY is provided")
	}
	return nil
}
// call before launching vmbackup
if err := requireAzureKeyPair(); err != nil {
	log.Fatal(err)
}

Try / catch

err := runBackup(ctx, cfg)
if err != nil && strings.Contains(err.Error(), "missing AZURE_STORAGE_ACCOUNT_NAME") {
	log.Fatalf("incomplete Azure env config: %v", err)
}

Prevention

When it happens

Trigger: Exporting AZURE_STORAGE_ACCOUNT_KEY (or placing it in the environment of the vmbackup process) without exporting AZURE_STORAGE_ACCOUNT_NAME, then running a backup/restore with an azblob:// destination.

Common situations: CI/CD secrets configured only partially (key secret set, name forgotten), shell profile exporting the key but not the name, renaming env vars when migrating from another Azure tool that used different names.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of VictoriaMetrics/VictoriaMetrics@5079fb58f1 (2026-09-03). Data as JSON: /api/errors/a5f2d12513b854c2. Report an issue: GitHub.