From cdafd156c9f816125d465c1f4fbd89846a544def Mon Sep 17 00:00:00 2001 From: Jesper Fajers Date: Sat, 6 Apr 2024 00:20:41 +0200 Subject: [PATCH] Update Template Api Versions (#872) * UpdateModule * Update-Command * UpdateApiVersions * UpdateApiVersion --- scripts/New-AzOpsTestsDeploymentHelper.ps1 | 4 +-- src/AzOps.psd1 | 6 ++-- src/data/template/template.json | 36 +++++++++---------- .../functions/New-AzOpsDeployment.ps1 | 2 +- src/tests/integration/Repository.Tests.ps1 | 2 +- src/tests/subscriptiononly/SubOnly.Tests.ps1 | 2 +- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/scripts/New-AzOpsTestsDeploymentHelper.ps1 b/scripts/New-AzOpsTestsDeploymentHelper.ps1 index 61d4e800..2c1da313 100644 --- a/scripts/New-AzOpsTestsDeploymentHelper.ps1 +++ b/scripts/New-AzOpsTestsDeploymentHelper.ps1 @@ -95,10 +95,10 @@ try { Write-PSFMessage -Level Verbose -Message "Deployment of $script:resourceType starting at $Scope scope." if ($script:templateParametersFile) { - $script:functionalTestDeploy = New-AzSubscriptionDeployment -Name ($script:resourceType + 'testdeploy') -TemplateFile $script:templateFile -TemplateParameterFile $script:templateParametersFile -Location $Location -Confirm:$false + $script:functionalTestDeploy = New-AzDeployment -Name ($script:resourceType + 'testdeploy') -TemplateFile $script:templateFile -TemplateParameterFile $script:templateParametersFile -Location $Location -Confirm:$false } else { - $script:functionalTestDeploy = New-AzSubscriptionDeployment -Name ($script:resourceType + 'testdeploy') -TemplateFile $script:templateFile -Location $Location -Confirm:$false + $script:functionalTestDeploy = New-AzDeployment -Name ($script:resourceType + 'testdeploy') -TemplateFile $script:templateFile -Location $Location -Confirm:$false } $script:return = [PSCustomObject]@{ functionalTestDeploy = $script:functionalTestDeploy diff --git a/src/AzOps.psd1 b/src/AzOps.psd1 index 41b8e5db..994476ca 100644 --- a/src/AzOps.psd1 +++ b/src/AzOps.psd1 @@ -3,7 +3,7 @@ # # Generated by: Customer Architecture Team (CAT) # -# Generated on: 03/21/2024 +# Generated on: 4/3/2024 # @{ @@ -52,10 +52,10 @@ PowerShellVersion = '7.2' # Modules that must be imported into the global environment prior to importing this module RequiredModules = @(@{ModuleName = 'PSFramework'; RequiredVersion = '1.10.318'; }, - @{ModuleName = 'Az.Accounts'; RequiredVersion = '2.16.0'; }, + @{ModuleName = 'Az.Accounts'; RequiredVersion = '2.17.0'; }, @{ModuleName = 'Az.Billing'; RequiredVersion = '2.0.3'; }, @{ModuleName = 'Az.ResourceGraph'; RequiredVersion = '0.13.0'; }, - @{ModuleName = 'Az.Resources'; RequiredVersion = '6.16.0'; }) + @{ModuleName = 'Az.Resources'; RequiredVersion = '6.16.1'; }) # Assemblies that must be loaded prior to importing this module # RequiredAssemblies = @() diff --git a/src/data/template/template.json b/src/data/template/template.json index 0a023a0a..d297fa2f 100644 --- a/src/data/template/template.json +++ b/src/data/template/template.json @@ -86,21 +86,21 @@ json('null') )]", "apiVersionLookup": { - "Microsoft.Resources/resourceGroups":"2020-06-01", - "Microsoft.Authorization/policyAssignments": "2020-03-01", - "Microsoft.Authorization/policyDefinitions": "2020-03-01", - "Microsoft.Authorization/PolicySetDefinitions": "2020-03-01", - "Microsoft.Authorization/roleDefinitions": "2018-01-01-preview", - "Microsoft.Authorization/roleAssignments": "2020-04-01-preview", - "Microsoft.PolicyInsights/remediations": "2019-07-01", - "Microsoft.ContainerService/ManagedClusters": "2020-09-01", - "Microsoft.KeyVault/vaults":"2019-09-01", + "Microsoft.Resources/resourceGroups":"2023-07-01", + "Microsoft.Authorization/policyAssignments": "2023-04-01", + "Microsoft.Authorization/policyDefinitions": "2023-04-01", + "Microsoft.Authorization/policySetDefinitions": "2023-04-01", + "Microsoft.Authorization/roleDefinitions": "2022-04-01", + "Microsoft.Authorization/roleAssignments": "2022-04-01", + "Microsoft.PolicyInsights/remediations": "2021-10-01", + "Microsoft.ContainerService/managedClusters": "2024-02-01", + "Microsoft.KeyVault/vaults":"2023-07-01", "Microsoft.Network/virtualWans": "2020-05-01", "Microsoft.Network/virtualHubs": "2020-05-01", "Microsoft.Network/virtualNetworks": "2020-06-01", "Microsoft.Network/azureFirewalls": "2020-06-01", - "/providers/Microsoft.Management/managementGroups": "2020-05-01", - "/subscriptions": "2020-05-01", + "/providers/Microsoft.Management/managementGroups": "2023-04-01", + "/subscriptions": "2021-10-01", "na": "9999-99-99", "": "0000-00-00" }, @@ -316,7 +316,7 @@ "scope": "[concat('Microsoft.Management/managementGroups/',parameters('input').name)]", */ "type": "Microsoft.Resources/deployments", - "apiVersion": "2019-10-01", + "apiVersion": "2023-07-01", "location": "[deployment().location]", "name": "[if( and(contains(parameters('input'), 'children'),not(empty(parameters('input').children))), @@ -411,7 +411,7 @@ }, "scope": "[concat('Microsoft.Management/managementGroups/',parameters('input').name)]", "type": "Microsoft.Resources/deployments", - "apiVersion": "2020-06-01", + "apiVersion": "2023-07-01", "location": "[deployment().location]", "name": "[if( and( @@ -509,7 +509,7 @@ }, "scope": "[concat('Microsoft.Management/managementGroups/',parameters('input').name)]", "type": "Microsoft.Resources/deployments", - "apiVersion": "2020-06-01", + "apiVersion": "2023-07-01", "location": "[deployment().location]", "name": "[if( and( @@ -608,7 +608,7 @@ }, "scope": "[concat('Microsoft.Management/managementGroups/',parameters('input').name)]", "type": "Microsoft.Resources/deployments", - "apiVersion": "2020-06-01", + "apiVersion": "2023-07-01", "location": "[deployment().location]", "name": "[if( and( @@ -705,7 +705,7 @@ }, "scope": "[concat('Microsoft.Management/managementGroups/',parameters('input').name)]", "type": "Microsoft.Resources/deployments", - "apiVersion": "2020-06-01", + "apiVersion": "2023-07-01", "location": "[deployment().location]", "name": "[if( and( @@ -802,7 +802,7 @@ }, "scope": "[concat('Microsoft.Management/managementGroups/',parameters('input').name)]", "type": "Microsoft.Resources/deployments", - "apiVersion": "2020-06-01", + "apiVersion": "2023-07-01", "location": "[deployment().location]", "name": "[if( and( @@ -885,4 +885,4 @@ "value": "[uri(parameters('_artifactsLocation'), concat('template.json', parameters('_artifactsLocationSasToken')))]" } } -} +} \ No newline at end of file diff --git a/src/internal/functions/New-AzOpsDeployment.ps1 b/src/internal/functions/New-AzOpsDeployment.ps1 index 542630dd..fc6917a7 100644 --- a/src/internal/functions/New-AzOpsDeployment.ps1 +++ b/src/internal/functions/New-AzOpsDeployment.ps1 @@ -130,7 +130,7 @@ Write-AzOpsMessage -LogLevel Verbose -LogString 'New-AzOpsDeployment.Subscription.Processing' -LogStringValues $defaultDeploymentRegion, $scopeObject -Target $scopeObject Set-AzOpsContext -ScopeObject $scopeObject $whatIfCommand = 'Get-AzSubscriptionDeploymentWhatIfResult' - $deploymentCommand = 'New-AzSubscriptionDeployment' + $deploymentCommand = 'New-AzDeployment' } # Management Groups elseif ($scopeObject.managementGroup -and (-not ($scopeObject.StatePath).StartsWith('azopsscope-assume-new-resource_'))) { diff --git a/src/tests/integration/Repository.Tests.ps1 b/src/tests/integration/Repository.Tests.ps1 index 1fb24ba0..108acce9 100644 --- a/src/tests/integration/Repository.Tests.ps1 +++ b/src/tests/integration/Repository.Tests.ps1 @@ -66,7 +66,7 @@ Describe "Repository" { Location = "northeurope" } try { - New-AzSubscriptionDeployment -Name 'AzOps-Tests-rbacdep' -Location northeurope -TemplateFile "$($global:testRoot)/templates/rbactest.bicep" -TemplateParameterFile "$($global:testRoot)/templates/rbactest.parameters.json" + New-AzDeployment -Name 'AzOps-Tests-rbacdep' -Location northeurope -TemplateFile "$($global:testRoot)/templates/rbactest.bicep" -TemplateParameterFile "$($global:testRoot)/templates/rbactest.parameters.json" New-AzManagementGroupDeployment @params New-AzResourceGroupDeployment -Name 'AzOps-Tests-policyuam' -ResourceGroupName App1-azopsrg -TemplateFile "$($global:testRoot)/templates/policywithuam.bicep" -TemplateParameterFile "$($global:testRoot)/templates/policywithuam.bicepparam" # Pause for resource consistency diff --git a/src/tests/subscriptiononly/SubOnly.Tests.ps1 b/src/tests/subscriptiononly/SubOnly.Tests.ps1 index 9551efe5..d9d16f09 100644 --- a/src/tests/subscriptiononly/SubOnly.Tests.ps1 +++ b/src/tests/subscriptiononly/SubOnly.Tests.ps1 @@ -53,7 +53,7 @@ Describe "SubscriptionOnly" { Write-PSFMessage -Level Verbose -Message "Creating repository test environment" -FunctionName "BeforeAll" try { - $rg = New-AzSubscriptionDeployment -Name 'AzOps-Tests-SubOnly-RG' -Location 'northeurope' -TemplateParameterFile "$($global:testRoot)/templates/rgsubonlydeploy.parameters.json" -TemplateFile "$($global:testRoot)/templates/rgsubonlydeploy.bicep" + $rg = New-AzDeployment -Name 'AzOps-Tests-SubOnly-RG' -Location 'northeurope' -TemplateParameterFile "$($global:testRoot)/templates/rgsubonlydeploy.parameters.json" -TemplateFile "$($global:testRoot)/templates/rgsubonlydeploy.bicep" $sta = New-AzResourceGroupDeployment -Name 'AzOps-Tests-SubOnly-Sta' -ResourceGroupName $rg.Parameters.resourceGroupName.Value -TemplateFile "$($global:testRoot)/templates/stasubonlydeploy.bicep" # Pause for resource consistency Start-Sleep -Seconds 120