From c893de7a1b50dad2100ed25ccb58b2bc3d5656c6 Mon Sep 17 00:00:00 2001 From: Ann Lu Date: Mon, 13 Feb 2023 12:00:56 +0800 Subject: [PATCH] Fix Invalid URI issue when passing diaplsy name of location (+1 squashed commits) Squashed commits: [bc81f1915fb] Fix Invalid URI issue when passing diaplsy name of location --- .../custom/New-AzConnectedKubernetes.ps1 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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