diff --git a/oci/auth/azure/auth.go b/oci/auth/azure/auth.go index 7a11ce97c..c48c3810e 100644 --- a/oci/auth/azure/auth.go +++ b/oci/auth/azure/auth.go @@ -74,10 +74,16 @@ func (c *Client) getLoginAuth(ctx context.Context, registryURL string) (authn.Au c.credential = cred } + var configurationEnvironmentLookupMap = map[string]cloud.Configuration{ + "io": cloud.AzurePublic, + "de": cloud.AzurePublic, // Azure Germany is not supported by Azure SDK for Go + "us": cloud.AzureGovernment, + "cn": cloud.AzureChina, + } + var azureEndpoint = registryURL[len(registryURL)-2:] // Obtain access token using the token credential. - // TODO: Add support for other azure endpoints as well. armToken, err := c.credential.GetToken(ctx, policy.TokenRequestOptions{ - Scopes: []string{cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + "/" + ".default"}, + Scopes: []string{configurationEnvironmentLookupMap[azureEndpoint].Services[cloud.ResourceManager].Endpoint + "/" + ".default"}, }) if err != nil { return authConfig, err