How can I specify the domain for an azure storage account?

After reading the documentation, I set these environment variables for backing up to azure blob storage.

AZURE_ACCOUNT_NAME=<account>.blob.core.usgovcloudapi.net
AZURE_ACCOUNT_KEY=<long secret>

But this configuration always throws the below error for me:

restic init -v -r azure:backups:/

enter password for new repository:
enter password again:
Fatal: create repository at azure:backups:/ failed: open: NewBasicClient: azure: account name is not valid: it must be between 3 and 24 characters, and only may contain numbers and lowercase letters: <account>.blob.core.usgovcloudapi.net

The FQDN is too long for that variable. I can set it without the domain name, but now it tries to connect to blob.core.windows.net which is the wrong domain and fails with a gateway error:

restic init -v -r azure:backups:/

enter password for new repository:
enter password again:
Fatal: create repository at azure:backups:/ failed: container.CreateIfNotExists: Put “https://<account>.blob.core.windows.net/backups?restype=container”: Bad Gateway

How can I get restic to connect to blob.core.usgovcloudapi.net?

The code for the Azure connection is here: restic/azure.go at master · restic/restic · GitHub

It currently isn’t written such that you can specify a custom URL unfortunately, even when using AZURE_ACCOUNT_SAS instead of AZURE_ACCOUNT_KEY.

It would be interesting to get this to work though, could you open a feature request over at GitHub, with your example? Please complete the example with the environment values you tried when doing it “without the domain name” though so it’s super clear :slight_smile:

Seeing as it’s a gov-related URL, can you run builds of the master branch to test this or are you restricted to using only formally released versions?

EDIT: I just realized that if you can use rclone to access your blob storage, then you can use that with restic. See Preparing a new repository — restic 0.14.0 documentation for more information on how to use the rclone backend and thereby an rclone remote as a backend for restic.