Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions sdk/environments/from_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ func TestFromEndpoint_Public(t *testing.T) {
if actual.Name != "AzureCloud" {
t.Fatalf("expected the Environment name to be `AzureCloud` but got %q", actual.Name)
}

endpoint, ok := actual.ResourceManager.Endpoint()
if !ok {
t.Fatalf("refreshing MetaData from Endpoint: no `ResourceManager` endpoint was defined")
}
if *endpoint != "https://management.azure.com" {
t.Fatalf("expected the ResourceManager endpoint to be `https://management.azure.com` but got %q", *endpoint)
}
}

func TestFromEndpoint_USGovernment(t *testing.T) {
Expand All @@ -28,4 +36,12 @@ func TestFromEndpoint_USGovernment(t *testing.T) {
if actual.Name != "AzureUSGovernment" {
t.Fatalf("expected the Environment name to be `AzureUSGovernment` but got %q", actual.Name)
}

endpoint, ok := actual.ResourceManager.Endpoint()
if !ok {
t.Fatalf("refreshing MetaData from Endpoint: no `ResourceManager` endpoint was defined")
}
if *endpoint != "https://management.usgovcloudapi.net" {
t.Fatalf("expected the ResourceManager endpoint to be `https://management.usgovcloudapi.net` but got %q", *endpoint)
}
}
5 changes: 4 additions & 1 deletion sdk/internal/metadata/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"net"
"net/http"
"runtime"
"strings"
"time"
)

Expand Down Expand Up @@ -115,7 +116,9 @@ func (c *Client) GetMetaData(ctx context.Context) (*MetaData, error) {
OSSRDBMS: normalizeResourceId(metadata.OssrDbmsResourceId),
Synapse: normalizeResourceId(metadata.SynapseAnalyticsResourceId),
},
ResourceManagerEndpoint: metadata.ResourceManager,
// The resourceManager endpoint returned from the ARM metadata service is in an inconsistent format
// between clouds so sanitize it here to prevent downstream issues.
ResourceManagerEndpoint: strings.TrimRight(metadata.ResourceManager, "/"),
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/internal/metadata/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func TestGetMetaData(t *testing.T) {
OSSRDBMS: "https://ossrdbms-aad.database.windows.net",
Synapse: "https://dev.azuresynapse.net",
},
ResourceManagerEndpoint: "https://management.azure.com/",
ResourceManagerEndpoint: "https://management.azure.com",
}

m, err := client.GetMetaData(ctx)
Expand Down