1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-22 07:43:03 +00:00

Merge pull request #5141 from richgrov/missing-azure-env-error

Return error if AZURE_ACCOUNT_NAME not set
This commit is contained in:
Michael Eischer 2024-12-01 14:01:56 +01:00 committed by GitHub
commit 2f0049cd6c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View file

@ -0,0 +1,7 @@
Enhancement: Provide clear error message if AZURE_ACCOUNT_NAME is not set
If AZURE_ACCOUNT_NAME is not set, any command related to an Azure repository
would result in a misleading networking error. Restic will now detect this and
provide a clear warning that the variable is not defined.
https://github.com/restic/restic/pull/5141

View file

@ -62,6 +62,11 @@ func open(cfg Config, rt http.RoundTripper) (*Backend, error) {
} else { } else {
endpointSuffix = "core.windows.net" endpointSuffix = "core.windows.net"
} }
if cfg.AccountName == "" {
return nil, errors.Fatalf("unable to open Azure backend: Account name ($AZURE_ACCOUNT_NAME) is empty")
}
url := fmt.Sprintf("https://%s.blob.%s/%s", cfg.AccountName, endpointSuffix, cfg.Container) url := fmt.Sprintf("https://%s.blob.%s/%s", cfg.AccountName, endpointSuffix, cfg.Container)
opts := &azContainer.ClientOptions{ opts := &azContainer.ClientOptions{
ClientOptions: azcore.ClientOptions{ ClientOptions: azcore.ClientOptions{