Skip to content

Commit

Permalink
ALZ-Bicep-Accelerator Register missing resource provider (#595)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebassem authored Aug 1, 2023
1 parent e1146cb commit ad6fbf6
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions accelerator/pipeline-scripts/Deploy-ALZMGDiagnosticSettings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ param (
[Parameter()]
[String]$TopLevelMGPrefix = "$($env:TOP_LEVEL_MG_PREFIX)",

[Parameter()]
[String]$ManagementSubscriptionId = "$($env:MANAGEMENT_SUBSCRIPTION_ID)",

[Parameter()]
[String]$TemplateFile = "upstream-releases\$($env:UPSTREAM_RELEASE_VERSION)\infra-as-code\bicep\orchestration\mgDiagSettingsAll\mgDiagSettingsAll.bicep",

Expand All @@ -26,4 +29,31 @@ $inputObject = @{
Verbose = $true
}

# Registering 'Microsoft.Insights' resource provider on the Management subscription
Select-AzSubscription -SubscriptionId $ManagementSubscriptionId

$providers = @('Microsoft.insights')

foreach ($provider in $providers ){
$iterationCount = 0
$maxIterations = 30
$providerStatus= (Get-AzResourceProvider -ListAvailable | Where-Object ProviderNamespace -eq $provider).registrationState
if($providerStatus -ne 'Registered'){
Write-Output "`n Registering the '$provider' provider"
Register-AzResourceProvider -ProviderNamespace $provider
do {
$providerStatus= (Get-AzResourceProvider -ListAvailable | Where-Object ProviderNamespace -eq $provider).registrationState
$iterationCount++
Write-Output "Waiting for the '$provider' provider registration to complete....waiting 10 seconds"
Start-Sleep -Seconds 10
} until ($providerStatus -eq 'Registered' -and $iterationCount -ne $maxIterations)
if($iterationCount -ne $maxIterations){
Write-Output "`n The '$provider' has been registered successfully"
}
else{
Write-Output "`n The '$provider' has not been registered successfully"
}
}
}

New-AzManagementGroupDeployment @inputObject

0 comments on commit ad6fbf6

Please sign in to comment.