diff --git a/src/ConnectedKubernetes/custom/New-AzConnectedKubernetes.ps1 b/src/ConnectedKubernetes/custom/New-AzConnectedKubernetes.ps1 index 895445dde635..e671d6d7d00e 100644 --- a/src/ConnectedKubernetes/custom/New-AzConnectedKubernetes.ps1 +++ b/src/ConnectedKubernetes/custom/New-AzConnectedKubernetes.ps1 @@ -346,7 +346,15 @@ function New-AzConnectedKubernetes { } else { $ReleaseTrain = 'stable' } - $ChartLocationUrl = "https://${Location}.dp.kubernetesconfiguration.azure.com/azure-arc-k8sagents/GetLatestHelmPackagePath?api-version=2019-11-01-preview&releaseTrain=${ReleaseTrain}" + + $AzLocation = Get-AzLocation | Where-Object { ($_.DisplayName -ieq $Location) -or ($_.Location -ieq $Location)} + $Region = $AzLocation.Location + if ($null -eq $Region) { + Write-Error "Invalid location: $Location" + return + } + + $ChartLocationUrl = "https://${Region}.dp.kubernetesconfiguration.azure.com/azure-arc-k8sagents/GetLatestHelmPackagePath?api-version=2019-11-01-preview&releaseTrain=${ReleaseTrain}" $Uri = [System.Uri]::New($ChartLocationUrl) $Account = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile.DefaultContext.Account