From 0d93a1586f429f6df1dd2e97543a293644b1ef24 Mon Sep 17 00:00:00 2001 From: Jan Egil Ring Date: Thu, 9 May 2024 08:19:16 +0200 Subject: [PATCH] Update preprovision.ps1 Throw error if Microsoft.AzureStackHCI provider id is not retrieved. --- azure_jumpstart_hcibox/scripts/preprovision.ps1 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/azure_jumpstart_hcibox/scripts/preprovision.ps1 b/azure_jumpstart_hcibox/scripts/preprovision.ps1 index de4b3aa92f..bebf219002 100644 --- a/azure_jumpstart_hcibox/scripts/preprovision.ps1 +++ b/azure_jumpstart_hcibox/scripts/preprovision.ps1 @@ -166,8 +166,12 @@ azd env set JS_RDP_PORT $JS_RDP_PORT # Attempt to retrieve provider id for Microsoft.AzureStackHCI Write-Host "Attempting to retrieve Microsoft.AzureStackHCI provider id..." $spnProviderId=$(az ad sp list --display-name "Microsoft.AzureStackHCI" --output json) | ConvertFrom-Json -if ($null -ne $spnProviderId.id) { - azd env set SPN_PROVIDER_ID -- $($spnProviderId.id) + else { + Write-Warning "Microsoft.AzureStackHCI provider id not found, aborting..." + + Write-Host 'Consider the following options: 1) Request access from a tenant administrator to get read-permissions to service principals. + 2) Ask a tenant administrator to run the command $(az ad sp list --display-name "Microsoft.AzureStackHCI" --output json) | ConvertFrom-Json and send you the ID from the output. You can then manually add that value to the AZD .env file: SPN_PROVIDER_ID="xxx" or use the Bicep-based deployment specifying spnProviderId="xxx" in the deployment parameter-file.' -ForegroundColor Yellow + throw "Microsoft.AzureStackHCI provider id not found" } ########################################################################