From 25a839f4c00b4d4ecc0b90ab74cb85de81bc08f2 Mon Sep 17 00:00:00 2001 From: Erika Gressi Date: Wed, 19 Oct 2022 19:20:01 +0200 Subject: [PATCH 01/10] min and empty rgs no pester --- .github/workflows/ms.compute.disks.yml | 39 +++-- .../.scripts/Copy-VhdToStorageAccount.ps1 | 124 +++++++++++++++ .../.test/.scripts/Start-ImageTemplate.ps1 | 79 ++++++++++ .../disks/.test/common/deploy.test.bicep | 63 ++++++++ .../disks/.test/image.parameters.json | 56 +++---- .../disks/.test/image/dependencies.bicep | 149 ++++++++++++++++++ .../disks/.test/image/dependencies_rbac.bicep | 16 ++ .../disks/.test/image/deploy.test.bicep | 63 ++++++++ .../disks/.test/import.parameters.json | 62 ++++---- .../disks/.test/import/deploy.test.bicep | 63 ++++++++ .../disks/.test/min.parameters.json | 50 +++--- .../disks/.test/min/deploy.test.bicep | 38 +++++ .../disks/.test/parameters.json | 86 +++++----- 13 files changed, 741 insertions(+), 147 deletions(-) create mode 100644 modules/Microsoft.Compute/disks/.test/.scripts/Copy-VhdToStorageAccount.ps1 create mode 100644 modules/Microsoft.Compute/disks/.test/.scripts/Start-ImageTemplate.ps1 create mode 100644 modules/Microsoft.Compute/disks/.test/common/deploy.test.bicep create mode 100644 modules/Microsoft.Compute/disks/.test/image/dependencies.bicep create mode 100644 modules/Microsoft.Compute/disks/.test/image/dependencies_rbac.bicep create mode 100644 modules/Microsoft.Compute/disks/.test/image/deploy.test.bicep create mode 100644 modules/Microsoft.Compute/disks/.test/import/deploy.test.bicep create mode 100644 modules/Microsoft.Compute/disks/.test/min/deploy.test.bicep diff --git a/.github/workflows/ms.compute.disks.yml b/.github/workflows/ms.compute.disks.yml index 389bd0f063..010fd2ae7f 100644 --- a/.github/workflows/ms.compute.disks.yml +++ b/.github/workflows/ms.compute.disks.yml @@ -63,23 +63,23 @@ jobs: ######################### # Static validation # ######################### - job_module_pester_validation: - runs-on: ubuntu-20.04 - name: 'Static validation' - steps: - - name: 'Checkout' - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Set environment variables - uses: ./.github/actions/templates/setEnvironmentVariables - with: - variablesPath: ${{ env.variablesPath }} - - name: 'Run tests' - uses: ./.github/actions/templates/validateModulePester - with: - modulePath: '${{ env.modulePath }}' - moduleTestFilePath: '${{ env.moduleTestFilePath }}' + # job_module_pester_validation: + # runs-on: ubuntu-20.04 + # name: 'Static validation' + # steps: + # - name: 'Checkout' + # uses: actions/checkout@v2 + # with: + # fetch-depth: 0 + # - name: Set environment variables + # uses: ./.github/actions/templates/setEnvironmentVariables + # with: + # variablesPath: ${{ env.variablesPath }} + # - name: 'Run tests' + # uses: ./.github/actions/templates/validateModulePester + # with: + # modulePath: '${{ env.modulePath }}' + # moduleTestFilePath: '${{ env.moduleTestFilePath }}' ############################# # Deployment validation # @@ -89,7 +89,7 @@ jobs: name: 'Deployment validation' needs: - job_initialize_pipeline - - job_module_pester_validation + # - job_module_pester_validation strategy: fail-fast: false matrix: @@ -106,8 +106,7 @@ jobs: - name: 'Using test file [${{ matrix.moduleTestFilePaths }}]' uses: ./.github/actions/templates/validateModuleDeployment with: - templateFilePath: '${{ env.modulePath }}/deploy.bicep' - parameterFilePath: '${{ env.modulePath }}/${{ matrix.moduleTestFilePaths }}' + templateFilePath: '${{ env.modulePath }}/${{ matrix.moduleTestFilePaths }}' location: '${{ env.location }}' resourceGroupName: '${{ env.resourceGroupName }}' subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}' diff --git a/modules/Microsoft.Compute/disks/.test/.scripts/Copy-VhdToStorageAccount.ps1 b/modules/Microsoft.Compute/disks/.test/.scripts/Copy-VhdToStorageAccount.ps1 new file mode 100644 index 0000000000..ff8568b0a9 --- /dev/null +++ b/modules/Microsoft.Compute/disks/.test/.scripts/Copy-VhdToStorageAccount.ps1 @@ -0,0 +1,124 @@ +<# + .SYNOPSIS + Copy a VHD baked from a given image template to a given destination storage account blob container + + .DESCRIPTION + Copy a VHD baked from a given image template to a given destination storage account blob container + + .PARAMETER ImageTemplateName + Mandatory. The name of the image template + + .PARAMETER ImageTemplateResourceGroup + Mandatory. The resource group name of the image template + + .PARAMETER DestinationStorageAccountName + Mandatory. The name of the destination storage account + + .PARAMETER DestinationContainerName + Optional. The name of the existing destination blob container + + .PARAMETER VhdName + Optional. Specify a different name for the destination VHD file + + .PARAMETER WaitForComplete + Optional. Run the command synchronously. Wait for the completion of the copy. + + .EXAMPLE + Copy-VhdToStorageAccount -ImageTemplateName 'vhd-img-template-001-2022-07-29-15-54-01' -ImageTemplateResourceGroup 'validation-rg' -DestinationStorageAccountName 'vhdstorage001' + + Copy a VHD created by image template 'vhd-img-template-001-2022-07-29-15-54-01' in resource group 'validation-rg' to destination storage account 'vhdstorage001' in blob container named 'vhds'. Save the VHD file as 'vhd-img-template-001-2022-07-29-15-54-01.vhd'. + + .EXAMPLE + Copy-VhdToStorageAccount -ImageTemplateName 'vhd-img-template-001-2022-07-29-15-54-01' -ImageTemplateResourceGroup 'validation-rg' -DestinationStorageAccountName 'vhdstorage001' -VhdName 'vhd-img-template-001' -WaitForComplete + + Copy a VHD baked by image template 'vhd-img-template-001-2022-07-29-15-54-01' in resource group 'validation-rg' to destination storage account 'vhdstorage001' in a blob container named 'vhds' and wait for the completion of the copy. Save the VHD file as 'vhd-img-template-001.vhd'. +#> + +[CmdletBinding(SupportsShouldProcess)] +param ( + [Parameter(Mandatory = $true)] + [string] $ImageTemplateName, + + [Parameter(Mandatory = $true)] + [string] $ImageTemplateResourceGroup, + + [Parameter(Mandatory = $true)] + [string] $DestinationStorageAccountName, + + [Parameter(Mandatory = $false)] + [string] $DestinationContainerName = 'vhds', + + [Parameter(Mandatory = $false)] + [string] $VhdName = $ImageTemplateName, + + [Parameter(Mandatory = $false)] + [switch] $WaitForComplete +) + +begin { + Write-Debug ('{0} entered' -f $MyInvocation.MyCommand) + + # Install required modules + $currentVerbosePreference = $VerbosePreference + $VerbosePreference = 'SilentlyContinue' + $requiredModules = @( + 'Az.ImageBuilder', + 'Az.Storage' + ) + foreach ($moduleName in $requiredModules) { + if (-not ($installedModule = Get-Module $moduleName -ListAvailable)) { + Install-Module $moduleName -Repository 'PSGallery' -Force -Scope 'CurrentUser' + if ($installed = Get-Module -Name $moduleName -ListAvailable) { + Write-Verbose ('Installed module [{0}] with version [{1}]' -f $installed.Name, $installed.Version) -Verbose + } + } else { + Write-Verbose ('Module [{0}] already installed in version [{1}]' -f $installedModule[0].Name, $installedModule[0].Version) -Verbose + } + } + $VerbosePreference = $currentVerbosePreference +} + +process { + # Retrieving and initializing parameters before the blob copy + Write-Verbose 'Initializing source storage account parameters before the blob copy' -Verbose + Write-Verbose ('Retrieving source storage account from image template [{0}] in resource group [{1}]' -f $imageTemplateName, $imageTemplateResourceGroup) -Verbose + Get-InstalledModule + $imgtRunOutput = Get-AzImageBuilderTemplateRunOutput -ImageTemplateName $imageTemplateName -ResourceGroupName $imageTemplateResourceGroup | Where-Object ArtifactUri -NE $null + $sourceUri = $imgtRunOutput.ArtifactUri + $sourceStorageAccountName = $sourceUri.Split('//')[1].Split('.')[0] + $storageAccountList = Get-AzStorageAccount + $sourceStorageAccount = $storageAccountList | Where-Object StorageAccountName -EQ $sourceStorageAccountName + $sourceStorageAccountContext = $sourceStorageAccount.Context + $sourceStorageAccountRGName = $sourceStorageAccount.ResourceGroupName + Write-Verbose ('Retrieving artifact uri [{0}] stored in resource group [{1}]' -f $sourceUri, $sourceStorageAccountRGName) -Verbose + + Write-Verbose 'Initializing destination storage account parameters before the blob copy' -Verbose + $destinationStorageAccount = $storageAccountList | Where-Object StorageAccountName -EQ $destinationStorageAccountName + $destinationStorageAccountContext = $destinationStorageAccount.Context + $destinationBlobName = "$vhdName.vhd" + Write-Verbose ('Planning for destination blob name [{0}] in container [{1}] and storage account [{2}]' -f $destinationBlobName, $destinationContainerName, $destinationStorageAccountName) -Verbose + + # Copying the VHD to a destination blob container + $resourceActionInputObject = @{ + AbsoluteUri = $sourceUri + Context = $sourceStorageAccountContext + DestContext = $destinationStorageAccountContext + DestBlob = $destinationBlobName + DestContainer = $destinationContainerName + Force = $true + } + + if ($PSCmdlet.ShouldProcess('Storage blob copy of VHD [{0}]' -f $destinationBlobName, 'Start')) { + $destBlob = Start-AzStorageBlobCopy @resourceActionInputObject + Write-Verbose ('Copied/initialized copy of VHD from URI [{0}] to container [{1}] in storage account [{2}]' -f $sourceUri, $destinationContainerName, $destinationStorageAccountName) -Verbose + } + + if ($WaitForComplete) { + $destBlob | Get-AzStorageBlobCopyState -WaitForComplete + } +} + +end { + Write-Debug ('{0} exited' -f $MyInvocation.MyCommand) +} + diff --git a/modules/Microsoft.Compute/disks/.test/.scripts/Start-ImageTemplate.ps1 b/modules/Microsoft.Compute/disks/.test/.scripts/Start-ImageTemplate.ps1 new file mode 100644 index 0000000000..9118832ea3 --- /dev/null +++ b/modules/Microsoft.Compute/disks/.test/.scripts/Start-ImageTemplate.ps1 @@ -0,0 +1,79 @@ +<# + .SYNOPSIS + Create image artifacts from a given image template + + .DESCRIPTION + Create image artifacts from a given image template + + .PARAMETER ImageTemplateName + Mandatory. The name of the image template + + .PARAMETER ImageTemplateResourceGroup + Mandatory. The resource group name of the image template + + .PARAMETER NoWait + Optional. Run the command asynchronously + + .EXAMPLE + Start-AzImageBuilderTemplate -ImageTemplateName 'vhd-img-template-001-2022-07-29-15-54-01' -ImageTemplateResourceGroup 'validation-rg' + + Create image artifacts from image template 'vhd-img-template-001-2022-07-29-15-54-01' in resource group 'validation-rg' and wait for their completion + + .EXAMPLE + Start-AzImageBuilderTemplate -ImageTemplateName 'vhd-img-template-001-2022-07-29-15-54-01' -ImageTemplateResourceGroup 'validation-rg' -NoWait + + Start the creation of artifacts from image template 'vhd-img-template-001-2022-07-29-15-54-01' in resource group 'validation-rg' and do not wait for their completion +#> + +[CmdletBinding(SupportsShouldProcess)] +param ( + [Parameter(Mandatory = $true)] + [string] $ImageTemplateName, + + [Parameter(Mandatory = $true)] + [string] $ImageTemplateResourceGroup, + + [Parameter(Mandatory = $false)] + [switch] $NoWait +) + +begin { + Write-Debug ('{0} entered' -f $MyInvocation.MyCommand) + + # Install required modules + $currentVerbosePreference = $VerbosePreference + $VerbosePreference = 'SilentlyContinue' + $requiredModules = @( + 'Az.ImageBuilder' + ) + foreach ($moduleName in $requiredModules) { + if (-not ($installedModule = Get-Module $moduleName -ListAvailable)) { + Install-Module $moduleName -Repository 'PSGallery' -Force -Scope 'CurrentUser' + if ($installed = Get-Module -Name $moduleName -ListAvailable) { + Write-Verbose ('Installed module [{0}] with version [{1}]' -f $installed.Name, $installed.Version) -Verbose + } + } else { + Write-Verbose ('Module [{0}] already installed in version [{1}]' -f $installedModule[0].Name, $installedModule[0].Version) -Verbose + } + } + $VerbosePreference = $currentVerbosePreference +} + +process { + # Create image artifacts from existing image template + $resourceActionInputObject = @{ + ImageTemplateName = $imageTemplateName + ResourceGroupName = $imageTemplateResourceGroup + } + if ($NoWait) { + $resourceActionInputObject['NoWait'] = $true + } + if ($PSCmdlet.ShouldProcess('Image template [{0}]' -f $imageTemplateName, 'Start')) { + $null = Start-AzImageBuilderTemplate @resourceActionInputObject + Write-Verbose ('Created/initialized creation of image artifacts from image template [{0}] in resource group [{1}]' -f $imageTemplateName, $imageTemplateResourceGroup) -Verbose + } +} + +end { + Write-Debug ('{0} exited' -f $MyInvocation.MyCommand) +} diff --git a/modules/Microsoft.Compute/disks/.test/common/deploy.test.bicep b/modules/Microsoft.Compute/disks/.test/common/deploy.test.bicep new file mode 100644 index 0000000000..469868bb3d --- /dev/null +++ b/modules/Microsoft.Compute/disks/.test/common/deploy.test.bicep @@ -0,0 +1,63 @@ +targetScope = 'subscription' + +// ========== // +// Parameters // +// ========== // + +@description('Optional. The name of the resource group to deploy for a testing purposes') +@maxLength(90) +param resourceGroupName string = 'ms.compute.images-${serviceShort}-rg' + +@description('Optional. The location to deploy resources to') +param location string = deployment().location + +@description('Optional. A short identifier for the kind of deployment. Should be kept short to not run into resource-name length-constraints') +param serviceShort string = 'cdcom' + +// =========== // +// Deployments // +// =========== // + +// General resources +// ================= +resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { + name: resourceGroupName + location: location +} + +// module resourceGroupResources 'dependencies.bicep' = { +// scope: resourceGroup +// name: '${uniqueString(deployment().name, location)}-paramNested' +// params: { +// managedIdentityName: 'dep-<>-msi-${serviceShort}' +// storageAccountName: 'dep<>sa${serviceShort}01' +// imageTemplateNamePrefix: 'dep-<>-imgt-${serviceShort}' +// triggerImageDeploymentScriptName: 'dep-<>-ds-${serviceShort}-triggerImageTemplate' +// copyVhdDeploymentScriptName: 'dep-<>-ds-${serviceShort}-copyVhdToStorage' +// } +// } + +// // ============== // +// // Test Execution // +// // ============== // +// module testDeployment '../../deploy.bicep' = { +// scope: resourceGroup +// name: '${uniqueString(deployment().name, location)}-test-${serviceShort}' +// params: { +// name: '<>${serviceShort}001' +// osAccountType: 'Premium_LRS' +// osDiskBlobUri: resourceGroupResources.outputs.vhdUri +// osDiskCaching: 'ReadWrite' +// osType: 'Windows' +// hyperVGeneration: 'V1' +// roleAssignments: [ +// { +// principalIds: [ +// resourceGroupResources.outputs.managedIdentityPrincipalId +// ] +// roleDefinitionIdOrName: 'Reader' +// } +// ] +// zoneResilient: true +// } +// } diff --git a/modules/Microsoft.Compute/disks/.test/image.parameters.json b/modules/Microsoft.Compute/disks/.test/image.parameters.json index d6934ac643..a3c346e7d5 100644 --- a/modules/Microsoft.Compute/disks/.test/image.parameters.json +++ b/modules/Microsoft.Compute/disks/.test/image.parameters.json @@ -1,28 +1,28 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "name": { - "value": "<>-az-disk-image-001" - }, - "sku": { - "value": "Standard_LRS" - }, - "createOption": { - "value": "FromImage" - }, - "imageReferenceId": { - "value": "/Subscriptions/<>/Providers/Microsoft.Compute/Locations/westeurope/Publishers/MicrosoftWindowsServer/ArtifactTypes/VMImage/Offers/WindowsServer/Skus/2016-Datacenter/Versions/14393.4906.2112080838" - }, - "roleAssignments": { - "value": [ - { - "roleDefinitionIdOrName": "Reader", - "principalIds": [ - "<>" - ] - } - ] - } - } -} +// { +// "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", +// "contentVersion": "1.0.0.0", +// "parameters": { +// "name": { +// "value": "<>-az-disk-image-001" +// }, +// "sku": { +// "value": "Standard_LRS" +// }, +// "createOption": { +// "value": "FromImage" +// }, +// "imageReferenceId": { +// "value": "/Subscriptions/<>/Providers/Microsoft.Compute/Locations/westeurope/Publishers/MicrosoftWindowsServer/ArtifactTypes/VMImage/Offers/WindowsServer/Skus/2016-Datacenter/Versions/14393.4906.2112080838" +// }, +// "roleAssignments": { +// "value": [ +// { +// "roleDefinitionIdOrName": "Reader", +// "principalIds": [ +// "<>" +// ] +// } +// ] +// } +// } +// } diff --git a/modules/Microsoft.Compute/disks/.test/image/dependencies.bicep b/modules/Microsoft.Compute/disks/.test/image/dependencies.bicep new file mode 100644 index 0000000000..d422b9c273 --- /dev/null +++ b/modules/Microsoft.Compute/disks/.test/image/dependencies.bicep @@ -0,0 +1,149 @@ +@description('Optional. The location to deploy to.') +param location string = resourceGroup().location + +@description('Required. The name of the Managed Identity to create.') +param managedIdentityName string + +@description('Required. The name of the Storage Account to create and to copy the VHD into.') +param storageAccountName string + +@description('Required. The name prefix of the Image Template to create.') +param imageTemplateNamePrefix string + +@description('Generated. Do not provide a value! This date value is used to generate a unique image template name.') +param baseTime string = utcNow('yyyy-MM-dd-HH-mm-ss') + +@description('Required. The name of the Deployment Script to create for triggering the image creation.') +param triggerImageDeploymentScriptName string + +@description('Required. The name of the Deployment Script to copy the VHD to a destination storage account.') +param copyVhdDeploymentScriptName string + +resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2018-11-30' = { + name: managedIdentityName + location: location +} + +resource storageAccount 'Microsoft.Storage/storageAccounts@2021-09-01' = { + name: storageAccountName + location: location + kind: 'StorageV2' + sku: { + name: 'Standard_LRS' + } + properties: { + allowBlobPublicAccess: false + } + resource blobServices 'blobServices@2021-09-01' = { + name: 'default' + resource container 'containers@2021-09-01' = { + name: 'vhds' + properties: { + publicAccess: 'None' + } + } + } +} + +module roleAssignment 'dependencies_rbac.bicep' = { + name: '${deployment().name}-MSI-roleAssignment' + scope: subscription() + params: { + managedIdentityPrincipalId: managedIdentity.properties.principalId + managedIdentityResourceId: managedIdentity.id + } +} + +// Deploy image template +resource imageTemplate 'Microsoft.VirtualMachineImages/imageTemplates@2022-02-14' = { + name: '${imageTemplateNamePrefix}-${baseTime}' + location: location + identity: { + type: 'UserAssigned' + userAssignedIdentities: { + '${managedIdentity.id}': {} + } + } + properties: { + buildTimeoutInMinutes: 0 + vmProfile: { + vmSize: 'Standard_D2s_v3' + osDiskSizeGB: 127 + } + source: { + type: 'PlatformImage' + publisher: 'MicrosoftWindowsDesktop' + offer: 'Windows-10' + sku: '19h2-evd' + version: 'latest' + } + distribute: [ + { + type: 'VHD' + runOutputName: '${imageTemplateNamePrefix}-VHD' + artifactTags: {} + } + ] + customize: [ + { + restartTimeout: '30m' + type: 'WindowsRestart' + } + ] + } +} + +// Trigger VHD creation +resource triggerImageDeploymentScript 'Microsoft.Resources/deploymentScripts@2020-10-01' = { + name: triggerImageDeploymentScriptName + location: location + kind: 'AzurePowerShell' + identity: { + type: 'UserAssigned' + userAssignedIdentities: { + '${managedIdentity.id}': {} + } + } + properties: { + azPowerShellVersion: '8.0' + retentionInterval: 'P1D' + arguments: '-ImageTemplateName \\"${imageTemplate.name}\\" -ImageTemplateResourceGroup \\"${resourceGroup().name}\\"' + scriptContent: loadTextContent('../.scripts/Start-ImageTemplate.ps1') + cleanupPreference: 'OnSuccess' + forceUpdateTag: baseTime + } + dependsOn: [ + roleAssignment + ] +} + +// Copy VHD to destination storage account +resource copyVhdDeploymentScript 'Microsoft.Resources/deploymentScripts@2020-10-01' = { + name: copyVhdDeploymentScriptName + location: location + kind: 'AzurePowerShell' + identity: { + type: 'UserAssigned' + userAssignedIdentities: { + '${managedIdentity.id}': {} + } + } + properties: { + azPowerShellVersion: '8.0' + retentionInterval: 'P1D' + arguments: '-ImageTemplateName \\"${imageTemplate.name}\\" -ImageTemplateResourceGroup \\"${resourceGroup().name}\\" -DestinationStorageAccountName \\"${storageAccount.name}\\" -VhdName \\"${imageTemplateNamePrefix}\\" -WaitForComplete' + scriptContent: loadTextContent('../.scripts/Copy-VhdToStorageAccount.ps1') + cleanupPreference: 'OnSuccess' + forceUpdateTag: baseTime + } + dependsOn: [ triggerImageDeploymentScript ] +} + +@description('The URI of the created VHD.') +output vhdUri string = 'https://${storageAccount.name}.blob.core.windows.net/vhds/${imageTemplateNamePrefix}.vhd' + +@description('The principal ID of the created Managed Identity.') +output managedIdentityPrincipalId string = managedIdentity.properties.principalId + +@description('The resource ID of the created Managed Identity.') +output managedIdentityResourceId string = managedIdentity.id diff --git a/modules/Microsoft.Compute/disks/.test/image/dependencies_rbac.bicep b/modules/Microsoft.Compute/disks/.test/image/dependencies_rbac.bicep new file mode 100644 index 0000000000..cdca1b63bd --- /dev/null +++ b/modules/Microsoft.Compute/disks/.test/image/dependencies_rbac.bicep @@ -0,0 +1,16 @@ +targetScope = 'subscription' + +@description('Required. The resource ID of the created Managed Identity.') +param managedIdentityResourceId string + +@description('Required. The principal ID of the created Managed Identity.') +param managedIdentityPrincipalId string + +resource roleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { + name: guid(subscription().subscriptionId, 'Contributor', managedIdentityResourceId) + properties: { + roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c') // Contributor + principalId: managedIdentityPrincipalId + principalType: 'ServicePrincipal' + } +} diff --git a/modules/Microsoft.Compute/disks/.test/image/deploy.test.bicep b/modules/Microsoft.Compute/disks/.test/image/deploy.test.bicep new file mode 100644 index 0000000000..d3761144ff --- /dev/null +++ b/modules/Microsoft.Compute/disks/.test/image/deploy.test.bicep @@ -0,0 +1,63 @@ +targetScope = 'subscription' + +// ========== // +// Parameters // +// ========== // + +@description('Optional. The name of the resource group to deploy for a testing purposes') +@maxLength(90) +param resourceGroupName string = 'ms.compute.images-${serviceShort}-rg' + +@description('Optional. The location to deploy resources to') +param location string = deployment().location + +@description('Optional. A short identifier for the kind of deployment. Should be kept short to not run into resource-name length-constraints') +param serviceShort string = 'cdimg' + +// =========== // +// Deployments // +// =========== // + +// General resources +// ================= +resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { + name: resourceGroupName + location: location +} + +// module resourceGroupResources 'dependencies.bicep' = { +// scope: resourceGroup +// name: '${uniqueString(deployment().name, location)}-paramNested' +// params: { +// managedIdentityName: 'dep-<>-msi-${serviceShort}' +// storageAccountName: 'dep<>sa${serviceShort}01' +// imageTemplateNamePrefix: 'dep-<>-imgt-${serviceShort}' +// triggerImageDeploymentScriptName: 'dep-<>-ds-${serviceShort}-triggerImageTemplate' +// copyVhdDeploymentScriptName: 'dep-<>-ds-${serviceShort}-copyVhdToStorage' +// } +// } + +// // ============== // +// // Test Execution // +// // ============== // +// module testDeployment '../../deploy.bicep' = { +// scope: resourceGroup +// name: '${uniqueString(deployment().name, location)}-test-${serviceShort}' +// params: { +// name: '<>${serviceShort}001' +// osAccountType: 'Premium_LRS' +// osDiskBlobUri: resourceGroupResources.outputs.vhdUri +// osDiskCaching: 'ReadWrite' +// osType: 'Windows' +// hyperVGeneration: 'V1' +// roleAssignments: [ +// { +// principalIds: [ +// resourceGroupResources.outputs.managedIdentityPrincipalId +// ] +// roleDefinitionIdOrName: 'Reader' +// } +// ] +// zoneResilient: true +// } +// } diff --git a/modules/Microsoft.Compute/disks/.test/import.parameters.json b/modules/Microsoft.Compute/disks/.test/import.parameters.json index 808508ac65..4f66333c84 100644 --- a/modules/Microsoft.Compute/disks/.test/import.parameters.json +++ b/modules/Microsoft.Compute/disks/.test/import.parameters.json @@ -1,31 +1,31 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "name": { - "value": "<>-az-disk-import-001" - }, - "sku": { - "value": "Standard_LRS" - }, - "createOption": { - "value": "Import" - }, - "sourceUri": { - "value": "https://adp<>azsavhd001.blob.core.windows.net/vhds/adp-<>-az-imgt-vhd-001.vhd" - }, - "storageAccountId": { - "value": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Storage/storageAccounts/adp<>azsavhd001" - }, - "roleAssignments": { - "value": [ - { - "roleDefinitionIdOrName": "Reader", - "principalIds": [ - "<>" - ] - } - ] - } - } -} +// { +// "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", +// "contentVersion": "1.0.0.0", +// "parameters": { +// "name": { +// "value": "<>-az-disk-import-001" +// }, +// "sku": { +// "value": "Standard_LRS" +// }, +// "createOption": { +// "value": "Import" +// }, +// "sourceUri": { +// "value": "https://adp<>azsavhd001.blob.core.windows.net/vhds/adp-<>-az-imgt-vhd-001.vhd" +// }, +// "storageAccountId": { +// "value": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Storage/storageAccounts/adp<>azsavhd001" +// }, +// "roleAssignments": { +// "value": [ +// { +// "roleDefinitionIdOrName": "Reader", +// "principalIds": [ +// "<>" +// ] +// } +// ] +// } +// } +// } diff --git a/modules/Microsoft.Compute/disks/.test/import/deploy.test.bicep b/modules/Microsoft.Compute/disks/.test/import/deploy.test.bicep new file mode 100644 index 0000000000..72d43efab1 --- /dev/null +++ b/modules/Microsoft.Compute/disks/.test/import/deploy.test.bicep @@ -0,0 +1,63 @@ +targetScope = 'subscription' + +// ========== // +// Parameters // +// ========== // + +@description('Optional. The name of the resource group to deploy for a testing purposes') +@maxLength(90) +param resourceGroupName string = 'ms.compute.images-${serviceShort}-rg' + +@description('Optional. The location to deploy resources to') +param location string = deployment().location + +@description('Optional. A short identifier for the kind of deployment. Should be kept short to not run into resource-name length-constraints') +param serviceShort string = 'cdimp' + +// =========== // +// Deployments // +// =========== // + +// General resources +// ================= +resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { + name: resourceGroupName + location: location +} + +// module resourceGroupResources 'dependencies.bicep' = { +// scope: resourceGroup +// name: '${uniqueString(deployment().name, location)}-paramNested' +// params: { +// managedIdentityName: 'dep-<>-msi-${serviceShort}' +// storageAccountName: 'dep<>sa${serviceShort}01' +// imageTemplateNamePrefix: 'dep-<>-imgt-${serviceShort}' +// triggerImageDeploymentScriptName: 'dep-<>-ds-${serviceShort}-triggerImageTemplate' +// copyVhdDeploymentScriptName: 'dep-<>-ds-${serviceShort}-copyVhdToStorage' +// } +// } + +// // ============== // +// // Test Execution // +// // ============== // +// module testDeployment '../../deploy.bicep' = { +// scope: resourceGroup +// name: '${uniqueString(deployment().name, location)}-test-${serviceShort}' +// params: { +// name: '<>${serviceShort}001' +// osAccountType: 'Premium_LRS' +// osDiskBlobUri: resourceGroupResources.outputs.vhdUri +// osDiskCaching: 'ReadWrite' +// osType: 'Windows' +// hyperVGeneration: 'V1' +// roleAssignments: [ +// { +// principalIds: [ +// resourceGroupResources.outputs.managedIdentityPrincipalId +// ] +// roleDefinitionIdOrName: 'Reader' +// } +// ] +// zoneResilient: true +// } +// } diff --git a/modules/Microsoft.Compute/disks/.test/min.parameters.json b/modules/Microsoft.Compute/disks/.test/min.parameters.json index d19f33a37d..db3dacff14 100644 --- a/modules/Microsoft.Compute/disks/.test/min.parameters.json +++ b/modules/Microsoft.Compute/disks/.test/min.parameters.json @@ -1,25 +1,25 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "name": { - "value": "<>-az-disk-min-001" - }, - "sku": { - "value": "Standard_LRS" - }, - "diskSizeGB": { - "value": 1 - }, - "roleAssignments": { - "value": [ - { - "roleDefinitionIdOrName": "Reader", - "principalIds": [ - "<>" - ] - } - ] - } - } -} +// { +// "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", +// "contentVersion": "1.0.0.0", +// "parameters": { +// "name": { +// "value": "<>-az-disk-min-001" +// }, +// "sku": { +// "value": "Standard_LRS" +// }, +// "diskSizeGB": { +// "value": 1 +// }, +// "roleAssignments": { +// "value": [ +// { +// "roleDefinitionIdOrName": "Reader", +// "principalIds": [ +// "<>" +// ] +// } +// ] +// } +// } +// } diff --git a/modules/Microsoft.Compute/disks/.test/min/deploy.test.bicep b/modules/Microsoft.Compute/disks/.test/min/deploy.test.bicep new file mode 100644 index 0000000000..d55a1aaddd --- /dev/null +++ b/modules/Microsoft.Compute/disks/.test/min/deploy.test.bicep @@ -0,0 +1,38 @@ +targetScope = 'subscription' + +// ========== // +// Parameters // +// ========== // + +@description('Optional. The name of the resource group to deploy for a testing purposes') +@maxLength(90) +param resourceGroupName string = 'ms.compute.images-${serviceShort}-rg' + +@description('Optional. The location to deploy resources to') +param location string = deployment().location + +@description('Optional. A short identifier for the kind of deployment. Should be kept short to not run into resource-name length-constraints') +param serviceShort string = 'cdmin' + +// =========== // +// Deployments // +// =========== // + +// General resources +// ================= +resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { + name: resourceGroupName + location: location +} + +// ============== // +// Test Execution // +// ============== // +module testDeployment '../../deploy.bicep' = { + scope: resourceGroup + name: '${uniqueString(deployment().name, location)}-test-${serviceShort}' + params: { + name: '<>-${serviceShort}001' + sku: 'Standard_LRS' + } +} diff --git a/modules/Microsoft.Compute/disks/.test/parameters.json b/modules/Microsoft.Compute/disks/.test/parameters.json index 833336ee1e..a18cfe27bc 100644 --- a/modules/Microsoft.Compute/disks/.test/parameters.json +++ b/modules/Microsoft.Compute/disks/.test/parameters.json @@ -1,43 +1,43 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "name": { - "value": "<>-az-disk-x-001" - }, - "lock": { - "value": "CanNotDelete" - }, - "sku": { - "value": "UltraSSD_LRS" - }, - "diskSizeGB": { - "value": 128 - }, - "logicalSectorSize": { - "value": 512 - }, - "diskIOPSReadWrite": { - "value": 500 - }, - "diskMBpsReadWrite": { - "value": 60 - }, - "osType": { - "value": "Windows" - }, - "publicNetworkAccess": { - "value": "Enabled" - }, - "roleAssignments": { - "value": [ - { - "roleDefinitionIdOrName": "Reader", - "principalIds": [ - "<>" - ] - } - ] - } - } -} +// { +// "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", +// "contentVersion": "1.0.0.0", +// "parameters": { +// "name": { +// "value": "<>-az-disk-x-001" +// }, +// "lock": { +// "value": "CanNotDelete" +// }, +// "sku": { +// "value": "UltraSSD_LRS" +// }, +// "diskSizeGB": { +// "value": 128 +// }, +// "logicalSectorSize": { +// "value": 512 +// }, +// "diskIOPSReadWrite": { +// "value": 500 +// }, +// "diskMBpsReadWrite": { +// "value": 60 +// }, +// "osType": { +// "value": "Windows" +// }, +// "publicNetworkAccess": { +// "value": "Enabled" +// }, +// "roleAssignments": { +// "value": [ +// { +// "roleDefinitionIdOrName": "Reader", +// "principalIds": [ +// "<>" +// ] +// } +// ] +// } +// } +// } From 7cf7967094dd1f87dc1a51a953a5072b42871265 Mon Sep 17 00:00:00 2001 From: Erika Gressi Date: Wed, 19 Oct 2022 19:22:57 +0200 Subject: [PATCH 02/10] move dep scripts to import --- .../disks/.test/{image => import}/dependencies.bicep | 0 .../disks/.test/{image => import}/dependencies_rbac.bicep | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename modules/Microsoft.Compute/disks/.test/{image => import}/dependencies.bicep (100%) rename modules/Microsoft.Compute/disks/.test/{image => import}/dependencies_rbac.bicep (100%) diff --git a/modules/Microsoft.Compute/disks/.test/image/dependencies.bicep b/modules/Microsoft.Compute/disks/.test/import/dependencies.bicep similarity index 100% rename from modules/Microsoft.Compute/disks/.test/image/dependencies.bicep rename to modules/Microsoft.Compute/disks/.test/import/dependencies.bicep diff --git a/modules/Microsoft.Compute/disks/.test/image/dependencies_rbac.bicep b/modules/Microsoft.Compute/disks/.test/import/dependencies_rbac.bicep similarity index 100% rename from modules/Microsoft.Compute/disks/.test/image/dependencies_rbac.bicep rename to modules/Microsoft.Compute/disks/.test/import/dependencies_rbac.bicep From 178d4139a4d5f58dafb8cfe61e1245af8d0bebac Mon Sep 17 00:00:00 2001 From: Erika Gressi Date: Wed, 19 Oct 2022 19:36:30 +0200 Subject: [PATCH 03/10] diskSizeGB --- .../disks/.test/common/dependencies.bicep | 13 +++++ .../disks/.test/common/deploy.test.bicep | 56 +++++++------------ .../disks/.test/image/deploy.test.bicep | 13 +++++ .../disks/.test/import/deploy.test.bicep | 12 ++++ .../disks/.test/min/deploy.test.bicep | 1 + modules/Microsoft.Compute/disks/deploy.bicep | 4 +- 6 files changed, 61 insertions(+), 38 deletions(-) create mode 100644 modules/Microsoft.Compute/disks/.test/common/dependencies.bicep diff --git a/modules/Microsoft.Compute/disks/.test/common/dependencies.bicep b/modules/Microsoft.Compute/disks/.test/common/dependencies.bicep new file mode 100644 index 0000000000..f17c563bb2 --- /dev/null +++ b/modules/Microsoft.Compute/disks/.test/common/dependencies.bicep @@ -0,0 +1,13 @@ +@description('Optional. The location to deploy resources to.') +param location string = resourceGroup().location + +@description('Required. The name of the Managed Identity to create.') +param managedIdentityName string + +resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2018-11-30' = { + name: managedIdentityName + location: location +} + +@description('The resource ID of the created Managed Identity.') +output managedIdentityResourceId string = managedIdentity.id diff --git a/modules/Microsoft.Compute/disks/.test/common/deploy.test.bicep b/modules/Microsoft.Compute/disks/.test/common/deploy.test.bicep index 469868bb3d..781646372b 100644 --- a/modules/Microsoft.Compute/disks/.test/common/deploy.test.bicep +++ b/modules/Microsoft.Compute/disks/.test/common/deploy.test.bicep @@ -25,39 +25,23 @@ resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { location: location } -// module resourceGroupResources 'dependencies.bicep' = { -// scope: resourceGroup -// name: '${uniqueString(deployment().name, location)}-paramNested' -// params: { -// managedIdentityName: 'dep-<>-msi-${serviceShort}' -// storageAccountName: 'dep<>sa${serviceShort}01' -// imageTemplateNamePrefix: 'dep-<>-imgt-${serviceShort}' -// triggerImageDeploymentScriptName: 'dep-<>-ds-${serviceShort}-triggerImageTemplate' -// copyVhdDeploymentScriptName: 'dep-<>-ds-${serviceShort}-copyVhdToStorage' -// } -// } - -// // ============== // -// // Test Execution // -// // ============== // -// module testDeployment '../../deploy.bicep' = { -// scope: resourceGroup -// name: '${uniqueString(deployment().name, location)}-test-${serviceShort}' -// params: { -// name: '<>${serviceShort}001' -// osAccountType: 'Premium_LRS' -// osDiskBlobUri: resourceGroupResources.outputs.vhdUri -// osDiskCaching: 'ReadWrite' -// osType: 'Windows' -// hyperVGeneration: 'V1' -// roleAssignments: [ -// { -// principalIds: [ -// resourceGroupResources.outputs.managedIdentityPrincipalId -// ] -// roleDefinitionIdOrName: 'Reader' -// } -// ] -// zoneResilient: true -// } -// } +module resourceGroupResources 'dependencies.bicep' = { + scope: resourceGroup + name: '${uniqueString(deployment().name, location)}-paramNested' + params: { + managedIdentityName: 'dep-<>-msi-${serviceShort}' + } +} + +// ============== // +// Test Execution // +// ============== // +module testDeployment '../../deploy.bicep' = { + scope: resourceGroup + name: '${uniqueString(deployment().name, location)}-test-${serviceShort}' + params: { + name: '<>-${serviceShort}001' + sku: 'Standard_LRS' + diskSizeGB: 1 + } +} diff --git a/modules/Microsoft.Compute/disks/.test/image/deploy.test.bicep b/modules/Microsoft.Compute/disks/.test/image/deploy.test.bicep index d3761144ff..c27a95f570 100644 --- a/modules/Microsoft.Compute/disks/.test/image/deploy.test.bicep +++ b/modules/Microsoft.Compute/disks/.test/image/deploy.test.bicep @@ -61,3 +61,16 @@ resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { // zoneResilient: true // } // } + +// ============== // +// Test Execution // +// ============== // +module testDeployment '../../deploy.bicep' = { + scope: resourceGroup + name: '${uniqueString(deployment().name, location)}-test-${serviceShort}' + params: { + name: '<>-${serviceShort}001' + sku: 'Standard_LRS' + diskSizeGB: 1 + } +} diff --git a/modules/Microsoft.Compute/disks/.test/import/deploy.test.bicep b/modules/Microsoft.Compute/disks/.test/import/deploy.test.bicep index 72d43efab1..f8d1e65763 100644 --- a/modules/Microsoft.Compute/disks/.test/import/deploy.test.bicep +++ b/modules/Microsoft.Compute/disks/.test/import/deploy.test.bicep @@ -61,3 +61,15 @@ resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { // zoneResilient: true // } // } + +// // ============== // +// // Test Execution // +// // ============== // +// module testDeployment '../../deploy.bicep' = { +// scope: resourceGroup +// name: '${uniqueString(deployment().name, location)}-test-${serviceShort}' +// params: { +// name: '<>-${serviceShort}001' +// sku: 'Standard_LRS' +// } +// } diff --git a/modules/Microsoft.Compute/disks/.test/min/deploy.test.bicep b/modules/Microsoft.Compute/disks/.test/min/deploy.test.bicep index d55a1aaddd..6fb986db71 100644 --- a/modules/Microsoft.Compute/disks/.test/min/deploy.test.bicep +++ b/modules/Microsoft.Compute/disks/.test/min/deploy.test.bicep @@ -34,5 +34,6 @@ module testDeployment '../../deploy.bicep' = { params: { name: '<>-${serviceShort}001' sku: 'Standard_LRS' + diskSizeGB: 1 } } diff --git a/modules/Microsoft.Compute/disks/deploy.bicep b/modules/Microsoft.Compute/disks/deploy.bicep index b6d2a4216b..1cad9177d3 100644 --- a/modules/Microsoft.Compute/disks/deploy.bicep +++ b/modules/Microsoft.Compute/disks/deploy.bicep @@ -51,13 +51,13 @@ param sourceResourceId string = '' @description('Optional. If create option is Import, this is the URI of a blob to be imported into a managed disk.') param sourceUri string = '' -@description('Optional. Required if create option is Import. The Azure Resource Manager identifier of the storage account containing the blob to import as a disk.') +@description('Conditional. The Azure Resource Manager identifier of the storage account containing the blob to import as a disk. Required if create option is Import.') param storageAccountId string = '' @description('Optional. If create option is Upload, this is the size of the contents of the upload including the VHD footer.') param uploadSizeBytes int = 20972032 -@description('Optional. If create option is empty, this field is mandatory and it indicates the size of the disk to create.') +@description('Conditional. The size of the disk to create. Required if create option is Empty.') param diskSizeGB int = 0 @description('Optional. The number of IOPS allowed for this disk; only settable for UltraSSD disks.') From eb2b2c634ae1c5164f485ba9bba041e1f61ad1da Mon Sep 17 00:00:00 2001 From: Erika Gressi Date: Wed, 19 Oct 2022 19:43:01 +0200 Subject: [PATCH 04/10] image --- .../disks/.test/common/dependencies.bicep | 4 +- .../disks/.test/common/deploy.test.bicep | 8 +++ .../disks/.test/image/dependencies.bicep | 13 +++++ .../disks/.test/image/deploy.test.bicep | 54 ++++++------------- 4 files changed, 40 insertions(+), 39 deletions(-) create mode 100644 modules/Microsoft.Compute/disks/.test/image/dependencies.bicep diff --git a/modules/Microsoft.Compute/disks/.test/common/dependencies.bicep b/modules/Microsoft.Compute/disks/.test/common/dependencies.bicep index f17c563bb2..13ea7a4d97 100644 --- a/modules/Microsoft.Compute/disks/.test/common/dependencies.bicep +++ b/modules/Microsoft.Compute/disks/.test/common/dependencies.bicep @@ -9,5 +9,5 @@ resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2018- location: location } -@description('The resource ID of the created Managed Identity.') -output managedIdentityResourceId string = managedIdentity.id +@description('The principal ID of the created managed identity') +output managedIdentityPrincipalId string = managedIdentity.properties.principalId diff --git a/modules/Microsoft.Compute/disks/.test/common/deploy.test.bicep b/modules/Microsoft.Compute/disks/.test/common/deploy.test.bicep index 781646372b..1b4c0201d1 100644 --- a/modules/Microsoft.Compute/disks/.test/common/deploy.test.bicep +++ b/modules/Microsoft.Compute/disks/.test/common/deploy.test.bicep @@ -43,5 +43,13 @@ module testDeployment '../../deploy.bicep' = { name: '<>-${serviceShort}001' sku: 'Standard_LRS' diskSizeGB: 1 + roleAssignments: [ + { + roleDefinitionIdOrName: 'Reader' + principalIds: [ + resourceGroupResources.outputs.managedIdentityPrincipalId + ] + } + ] } } diff --git a/modules/Microsoft.Compute/disks/.test/image/dependencies.bicep b/modules/Microsoft.Compute/disks/.test/image/dependencies.bicep new file mode 100644 index 0000000000..13ea7a4d97 --- /dev/null +++ b/modules/Microsoft.Compute/disks/.test/image/dependencies.bicep @@ -0,0 +1,13 @@ +@description('Optional. The location to deploy resources to.') +param location string = resourceGroup().location + +@description('Required. The name of the Managed Identity to create.') +param managedIdentityName string + +resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2018-11-30' = { + name: managedIdentityName + location: location +} + +@description('The principal ID of the created managed identity') +output managedIdentityPrincipalId string = managedIdentity.properties.principalId diff --git a/modules/Microsoft.Compute/disks/.test/image/deploy.test.bicep b/modules/Microsoft.Compute/disks/.test/image/deploy.test.bicep index c27a95f570..b0825f7226 100644 --- a/modules/Microsoft.Compute/disks/.test/image/deploy.test.bicep +++ b/modules/Microsoft.Compute/disks/.test/image/deploy.test.bicep @@ -25,42 +25,13 @@ resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { location: location } -// module resourceGroupResources 'dependencies.bicep' = { -// scope: resourceGroup -// name: '${uniqueString(deployment().name, location)}-paramNested' -// params: { -// managedIdentityName: 'dep-<>-msi-${serviceShort}' -// storageAccountName: 'dep<>sa${serviceShort}01' -// imageTemplateNamePrefix: 'dep-<>-imgt-${serviceShort}' -// triggerImageDeploymentScriptName: 'dep-<>-ds-${serviceShort}-triggerImageTemplate' -// copyVhdDeploymentScriptName: 'dep-<>-ds-${serviceShort}-copyVhdToStorage' -// } -// } - -// // ============== // -// // Test Execution // -// // ============== // -// module testDeployment '../../deploy.bicep' = { -// scope: resourceGroup -// name: '${uniqueString(deployment().name, location)}-test-${serviceShort}' -// params: { -// name: '<>${serviceShort}001' -// osAccountType: 'Premium_LRS' -// osDiskBlobUri: resourceGroupResources.outputs.vhdUri -// osDiskCaching: 'ReadWrite' -// osType: 'Windows' -// hyperVGeneration: 'V1' -// roleAssignments: [ -// { -// principalIds: [ -// resourceGroupResources.outputs.managedIdentityPrincipalId -// ] -// roleDefinitionIdOrName: 'Reader' -// } -// ] -// zoneResilient: true -// } -// } +module resourceGroupResources 'dependencies.bicep' = { + scope: resourceGroup + name: '${uniqueString(deployment().name, location)}-paramNested' + params: { + managedIdentityName: 'dep-<>-msi-${serviceShort}' + } +} // ============== // // Test Execution // @@ -71,6 +42,15 @@ module testDeployment '../../deploy.bicep' = { params: { name: '<>-${serviceShort}001' sku: 'Standard_LRS' - diskSizeGB: 1 + createOption: 'FromImage' + imageReferenceId: '/Subscriptions/<>/Providers/Microsoft.Compute/Locations/westeurope/Publishers/MicrosoftWindowsServer/ArtifactTypes/VMImage/Offers/WindowsServer/Skus/2016-Datacenter/Versions/14393.4906.2112080838' + roleAssignments: [ + { + roleDefinitionIdOrName: 'Reader' + principalIds: [ + resourceGroupResources.outputs.managedIdentityPrincipalId + ] + } + ] } } From 112d54c84666aaabbd63138f30c7bc8fdd0fe70a Mon Sep 17 00:00:00 2001 From: Erika Gressi Date: Wed, 19 Oct 2022 19:50:22 +0200 Subject: [PATCH 05/10] common --- .../disks/.test/common/deploy.test.bicep | 10 ++++++++-- .../disks/.test/image/deploy.test.bicep | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/Microsoft.Compute/disks/.test/common/deploy.test.bicep b/modules/Microsoft.Compute/disks/.test/common/deploy.test.bicep index 1b4c0201d1..b97a860f7a 100644 --- a/modules/Microsoft.Compute/disks/.test/common/deploy.test.bicep +++ b/modules/Microsoft.Compute/disks/.test/common/deploy.test.bicep @@ -41,8 +41,14 @@ module testDeployment '../../deploy.bicep' = { name: '${uniqueString(deployment().name, location)}-test-${serviceShort}' params: { name: '<>-${serviceShort}001' - sku: 'Standard_LRS' - diskSizeGB: 1 + sku: 'UltraSSD_LRS' + diskIOPSReadWrite: 500 + diskMBpsReadWrite: 60 + diskSizeGB: 128 + lock: 'CanNotDelete' + logicalSectorSize: 512 + osType: 'Windows' + publicNetworkAccess: 'Enabled' roleAssignments: [ { roleDefinitionIdOrName: 'Reader' diff --git a/modules/Microsoft.Compute/disks/.test/image/deploy.test.bicep b/modules/Microsoft.Compute/disks/.test/image/deploy.test.bicep index b0825f7226..0476e90e8a 100644 --- a/modules/Microsoft.Compute/disks/.test/image/deploy.test.bicep +++ b/modules/Microsoft.Compute/disks/.test/image/deploy.test.bicep @@ -43,7 +43,7 @@ module testDeployment '../../deploy.bicep' = { name: '<>-${serviceShort}001' sku: 'Standard_LRS' createOption: 'FromImage' - imageReferenceId: '/Subscriptions/<>/Providers/Microsoft.Compute/Locations/westeurope/Publishers/MicrosoftWindowsServer/ArtifactTypes/VMImage/Offers/WindowsServer/Skus/2016-Datacenter/Versions/14393.4906.2112080838' + imageReferenceId: '${subscription().id}/Providers/Microsoft.Compute/Locations/westeurope/Publishers/MicrosoftWindowsServer/ArtifactTypes/VMImage/Offers/WindowsServer/Skus/2016-Datacenter/Versions/14393.4906.2112080838' roleAssignments: [ { roleDefinitionIdOrName: 'Reader' From c7e157cd6fc8dc36b0443bddd21dc1d054aab20c Mon Sep 17 00:00:00 2001 From: Erika Gressi Date: Wed, 19 Oct 2022 19:58:31 +0200 Subject: [PATCH 06/10] import --- .../disks/.test/import/dependencies.bicep | 3 + .../disks/.test/import/deploy.test.bicep | 55 +++++++++++-------- modules/Microsoft.Compute/disks/deploy.bicep | 2 +- 3 files changed, 37 insertions(+), 23 deletions(-) diff --git a/modules/Microsoft.Compute/disks/.test/import/dependencies.bicep b/modules/Microsoft.Compute/disks/.test/import/dependencies.bicep index d422b9c273..dad8af70fe 100644 --- a/modules/Microsoft.Compute/disks/.test/import/dependencies.bicep +++ b/modules/Microsoft.Compute/disks/.test/import/dependencies.bicep @@ -142,6 +142,9 @@ resource copyVhdDeploymentScript 'Microsoft.Resources/deploymentScripts@2020-10- @description('The URI of the created VHD.') output vhdUri string = 'https://${storageAccount.name}.blob.core.windows.net/vhds/${imageTemplateNamePrefix}.vhd' +@description('The resource ID of the created Storage Account.') +output storageAccountResourceId string = storageAccount.id + @description('The principal ID of the created Managed Identity.') output managedIdentityPrincipalId string = managedIdentity.properties.principalId diff --git a/modules/Microsoft.Compute/disks/.test/import/deploy.test.bicep b/modules/Microsoft.Compute/disks/.test/import/deploy.test.bicep index f8d1e65763..a3c95d1449 100644 --- a/modules/Microsoft.Compute/disks/.test/import/deploy.test.bicep +++ b/modules/Microsoft.Compute/disks/.test/import/deploy.test.bicep @@ -25,17 +25,17 @@ resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { location: location } -// module resourceGroupResources 'dependencies.bicep' = { -// scope: resourceGroup -// name: '${uniqueString(deployment().name, location)}-paramNested' -// params: { -// managedIdentityName: 'dep-<>-msi-${serviceShort}' -// storageAccountName: 'dep<>sa${serviceShort}01' -// imageTemplateNamePrefix: 'dep-<>-imgt-${serviceShort}' -// triggerImageDeploymentScriptName: 'dep-<>-ds-${serviceShort}-triggerImageTemplate' -// copyVhdDeploymentScriptName: 'dep-<>-ds-${serviceShort}-copyVhdToStorage' -// } -// } +module resourceGroupResources 'dependencies.bicep' = { + scope: resourceGroup + name: '${uniqueString(deployment().name, location)}-paramNested' + params: { + managedIdentityName: 'dep-<>-msi-${serviceShort}' + storageAccountName: 'dep<>sa${serviceShort}01' + imageTemplateNamePrefix: 'dep-<>-imgt-${serviceShort}' + triggerImageDeploymentScriptName: 'dep-<>-ds-${serviceShort}-triggerImageTemplate' + copyVhdDeploymentScriptName: 'dep-<>-ds-${serviceShort}-copyVhdToStorage' + } +} // // ============== // // // Test Execution // @@ -62,14 +62,25 @@ resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { // } // } -// // ============== // -// // Test Execution // -// // ============== // -// module testDeployment '../../deploy.bicep' = { -// scope: resourceGroup -// name: '${uniqueString(deployment().name, location)}-test-${serviceShort}' -// params: { -// name: '<>-${serviceShort}001' -// sku: 'Standard_LRS' -// } -// } +// ============== // +// Test Execution // +// ============== // +module testDeployment '../../deploy.bicep' = { + scope: resourceGroup + name: '${uniqueString(deployment().name, location)}-test-${serviceShort}' + params: { + name: '<>-${serviceShort}001' + sku: 'Standard_LRS' + createOption: 'Import' + roleAssignments: [ + { + roleDefinitionIdOrName: 'Reader' + principalIds: [ + resourceGroupResources.outputs.managedIdentityPrincipalId + ] + } + ] + sourceUri: resourceGroupResources.outputs.vhdUri + storageAccountId: resourceGroupResources.outputs.storageAccountResourceId + } +} diff --git a/modules/Microsoft.Compute/disks/deploy.bicep b/modules/Microsoft.Compute/disks/deploy.bicep index 1cad9177d3..afd0d9fabf 100644 --- a/modules/Microsoft.Compute/disks/deploy.bicep +++ b/modules/Microsoft.Compute/disks/deploy.bicep @@ -51,7 +51,7 @@ param sourceResourceId string = '' @description('Optional. If create option is Import, this is the URI of a blob to be imported into a managed disk.') param sourceUri string = '' -@description('Conditional. The Azure Resource Manager identifier of the storage account containing the blob to import as a disk. Required if create option is Import.') +@description('Conditional. The resource ID of the storage account containing the blob to import as a disk. Required if create option is Import.') param storageAccountId string = '' @description('Optional. If create option is Upload, this is the size of the contents of the upload including the VHD footer.') From a7dca5ed8374f95208eb5e404d50137d6645d705 Mon Sep 17 00:00:00 2001 From: Erika Gressi Date: Wed, 19 Oct 2022 20:10:12 +0200 Subject: [PATCH 07/10] delete old parameter files --- .../disks/.test/image.parameters.json | 28 ------------ .../disks/.test/import.parameters.json | 31 ------------- .../disks/.test/min.parameters.json | 25 ----------- .../disks/.test/parameters.json | 43 ------------------- 4 files changed, 127 deletions(-) delete mode 100644 modules/Microsoft.Compute/disks/.test/image.parameters.json delete mode 100644 modules/Microsoft.Compute/disks/.test/import.parameters.json delete mode 100644 modules/Microsoft.Compute/disks/.test/min.parameters.json delete mode 100644 modules/Microsoft.Compute/disks/.test/parameters.json diff --git a/modules/Microsoft.Compute/disks/.test/image.parameters.json b/modules/Microsoft.Compute/disks/.test/image.parameters.json deleted file mode 100644 index a3c346e7d5..0000000000 --- a/modules/Microsoft.Compute/disks/.test/image.parameters.json +++ /dev/null @@ -1,28 +0,0 @@ -// { -// "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", -// "contentVersion": "1.0.0.0", -// "parameters": { -// "name": { -// "value": "<>-az-disk-image-001" -// }, -// "sku": { -// "value": "Standard_LRS" -// }, -// "createOption": { -// "value": "FromImage" -// }, -// "imageReferenceId": { -// "value": "/Subscriptions/<>/Providers/Microsoft.Compute/Locations/westeurope/Publishers/MicrosoftWindowsServer/ArtifactTypes/VMImage/Offers/WindowsServer/Skus/2016-Datacenter/Versions/14393.4906.2112080838" -// }, -// "roleAssignments": { -// "value": [ -// { -// "roleDefinitionIdOrName": "Reader", -// "principalIds": [ -// "<>" -// ] -// } -// ] -// } -// } -// } diff --git a/modules/Microsoft.Compute/disks/.test/import.parameters.json b/modules/Microsoft.Compute/disks/.test/import.parameters.json deleted file mode 100644 index 4f66333c84..0000000000 --- a/modules/Microsoft.Compute/disks/.test/import.parameters.json +++ /dev/null @@ -1,31 +0,0 @@ -// { -// "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", -// "contentVersion": "1.0.0.0", -// "parameters": { -// "name": { -// "value": "<>-az-disk-import-001" -// }, -// "sku": { -// "value": "Standard_LRS" -// }, -// "createOption": { -// "value": "Import" -// }, -// "sourceUri": { -// "value": "https://adp<>azsavhd001.blob.core.windows.net/vhds/adp-<>-az-imgt-vhd-001.vhd" -// }, -// "storageAccountId": { -// "value": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Storage/storageAccounts/adp<>azsavhd001" -// }, -// "roleAssignments": { -// "value": [ -// { -// "roleDefinitionIdOrName": "Reader", -// "principalIds": [ -// "<>" -// ] -// } -// ] -// } -// } -// } diff --git a/modules/Microsoft.Compute/disks/.test/min.parameters.json b/modules/Microsoft.Compute/disks/.test/min.parameters.json deleted file mode 100644 index db3dacff14..0000000000 --- a/modules/Microsoft.Compute/disks/.test/min.parameters.json +++ /dev/null @@ -1,25 +0,0 @@ -// { -// "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", -// "contentVersion": "1.0.0.0", -// "parameters": { -// "name": { -// "value": "<>-az-disk-min-001" -// }, -// "sku": { -// "value": "Standard_LRS" -// }, -// "diskSizeGB": { -// "value": 1 -// }, -// "roleAssignments": { -// "value": [ -// { -// "roleDefinitionIdOrName": "Reader", -// "principalIds": [ -// "<>" -// ] -// } -// ] -// } -// } -// } diff --git a/modules/Microsoft.Compute/disks/.test/parameters.json b/modules/Microsoft.Compute/disks/.test/parameters.json deleted file mode 100644 index a18cfe27bc..0000000000 --- a/modules/Microsoft.Compute/disks/.test/parameters.json +++ /dev/null @@ -1,43 +0,0 @@ -// { -// "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", -// "contentVersion": "1.0.0.0", -// "parameters": { -// "name": { -// "value": "<>-az-disk-x-001" -// }, -// "lock": { -// "value": "CanNotDelete" -// }, -// "sku": { -// "value": "UltraSSD_LRS" -// }, -// "diskSizeGB": { -// "value": 128 -// }, -// "logicalSectorSize": { -// "value": 512 -// }, -// "diskIOPSReadWrite": { -// "value": 500 -// }, -// "diskMBpsReadWrite": { -// "value": 60 -// }, -// "osType": { -// "value": "Windows" -// }, -// "publicNetworkAccess": { -// "value": "Enabled" -// }, -// "roleAssignments": { -// "value": [ -// { -// "roleDefinitionIdOrName": "Reader", -// "principalIds": [ -// "<>" -// ] -// } -// ] -// } -// } -// } From 0c03877ef5000503cd2777afae3068e0523fb24e Mon Sep 17 00:00:00 2001 From: Erika Gressi Date: Wed, 19 Oct 2022 20:11:38 +0200 Subject: [PATCH 08/10] cleanup --- .../disks/.test/import/deploy.test.bicep | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/modules/Microsoft.Compute/disks/.test/import/deploy.test.bicep b/modules/Microsoft.Compute/disks/.test/import/deploy.test.bicep index a3c95d1449..d438d6a64c 100644 --- a/modules/Microsoft.Compute/disks/.test/import/deploy.test.bicep +++ b/modules/Microsoft.Compute/disks/.test/import/deploy.test.bicep @@ -37,31 +37,6 @@ module resourceGroupResources 'dependencies.bicep' = { } } -// // ============== // -// // Test Execution // -// // ============== // -// module testDeployment '../../deploy.bicep' = { -// scope: resourceGroup -// name: '${uniqueString(deployment().name, location)}-test-${serviceShort}' -// params: { -// name: '<>${serviceShort}001' -// osAccountType: 'Premium_LRS' -// osDiskBlobUri: resourceGroupResources.outputs.vhdUri -// osDiskCaching: 'ReadWrite' -// osType: 'Windows' -// hyperVGeneration: 'V1' -// roleAssignments: [ -// { -// principalIds: [ -// resourceGroupResources.outputs.managedIdentityPrincipalId -// ] -// roleDefinitionIdOrName: 'Reader' -// } -// ] -// zoneResilient: true -// } -// } - // ============== // // Test Execution // // ============== // From b1676f5a798061e782681ccb1c6436eae4db93c3 Mon Sep 17 00:00:00 2001 From: Erika Gressi Date: Wed, 19 Oct 2022 20:14:55 +0200 Subject: [PATCH 09/10] readme --- modules/Microsoft.Compute/disks/readme.md | 169 ++++++++++------------ 1 file changed, 78 insertions(+), 91 deletions(-) diff --git a/modules/Microsoft.Compute/disks/readme.md b/modules/Microsoft.Compute/disks/readme.md index 72dfd6d833..a83b0dd649 100644 --- a/modules/Microsoft.Compute/disks/readme.md +++ b/modules/Microsoft.Compute/disks/readme.md @@ -27,6 +27,13 @@ This template deploys a disk | `name` | string | | The name of the disk that is being created. | | `sku` | string | `[Premium_LRS, Premium_ZRS, Premium_ZRS, Standard_LRS, StandardSSD_LRS, UltraSSD_LRS]` | The disks sku name. Can be . | +**Conditional parameters** + +| Parameter Name | Type | Default Value | Description | +| :-- | :-- | :-- | :-- | +| `diskSizeGB` | int | `0` | The size of the disk to create. Required if create option is Empty. | +| `storageAccountId` | string | `''` | The resource ID of the storage account containing the blob to import as a disk. Required if create option is Import. | + **Optional parameters** | Parameter Name | Type | Default Value | Allowed Values | Description | @@ -37,7 +44,6 @@ This template deploys a disk | `createOption` | string | `'Empty'` | `[Attach, Copy, CopyStart, Empty, FromImage, Import, ImportSecure, Restore, Upload, UploadPreparedSecure]` | Sources of a disk creation. | | `diskIOPSReadWrite` | int | `0` | | The number of IOPS allowed for this disk; only settable for UltraSSD disks. | | `diskMBpsReadWrite` | int | `0` | | The bandwidth allowed for this disk; only settable for UltraSSD disks. | -| `diskSizeGB` | int | `0` | | If create option is empty, this field is mandatory and it indicates the size of the disk to create. | | `enableDefaultTelemetry` | bool | `True` | | Enable telemetry via the Customer Usage Attribution ID (GUID). | | `hyperVGeneration` | string | `'V2'` | `[V1, V2]` | The hypervisor generation of the Virtual Machine. Applicable to OS disks only. | | `imageReferenceId` | string | `''` | | A relative uri containing either a Platform Image Repository or user image reference. | @@ -52,7 +58,6 @@ This template deploys a disk | `securityDataUri` | string | `''` | | If create option is ImportSecure, this is the URI of a blob to be imported into VM guest state. | | `sourceResourceId` | string | `''` | | If create option is Copy, this is the ARM ID of the source snapshot or disk. | | `sourceUri` | string | `''` | | If create option is Import, this is the URI of a blob to be imported into a managed disk. | -| `storageAccountId` | string | `''` | | Required if create option is Import. The Azure Resource Manager identifier of the storage account containing the blob to import as a disk. | | `tags` | object | `{object}` | | Tags of the availability set resource. | | `uploadSizeBytes` | int | `20972032` | | If create option is Upload, this is the size of the contents of the upload including the VHD footer. | @@ -177,7 +182,7 @@ The following module usage examples are retrieved from the content of the files >**Note**: Each example lists all the required parameters first, followed by the rest - each in alphabetical order. -

Example 1: Image

+

Example 1: Common

@@ -185,18 +190,23 @@ The following module usage examples are retrieved from the content of the files ```bicep module disks './Microsoft.Compute/disks/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-Disks' + name: '${uniqueString(deployment().name, location)}-test-cdcom' params: { // Required parameters - name: '<>-az-disk-image-001' - sku: 'Standard_LRS' + name: '<>-cdcom001' + sku: 'UltraSSD_LRS' // Non-required parameters - createOption: 'FromImage' - imageReferenceId: '/Subscriptions/<>/Providers/Microsoft.Compute/Locations/westeurope/Publishers/MicrosoftWindowsServer/ArtifactTypes/VMImage/Offers/WindowsServer/Skus/2016-Datacenter/Versions/14393.4906.2112080838' + diskIOPSReadWrite: 500 + diskMBpsReadWrite: 60 + diskSizeGB: 128 + lock: 'CanNotDelete' + logicalSectorSize: 512 + osType: 'Windows' + publicNetworkAccess: 'Enabled' roleAssignments: [ { principalIds: [ - '<>' + '' ] roleDefinitionIdOrName: 'Reader' } @@ -219,23 +229,38 @@ module disks './Microsoft.Compute/disks/deploy.bicep' = { "parameters": { // Required parameters "name": { - "value": "<>-az-disk-image-001" + "value": "<>-cdcom001" }, "sku": { - "value": "Standard_LRS" + "value": "UltraSSD_LRS" }, // Non-required parameters - "createOption": { - "value": "FromImage" + "diskIOPSReadWrite": { + "value": 500 }, - "imageReferenceId": { - "value": "/Subscriptions/<>/Providers/Microsoft.Compute/Locations/westeurope/Publishers/MicrosoftWindowsServer/ArtifactTypes/VMImage/Offers/WindowsServer/Skus/2016-Datacenter/Versions/14393.4906.2112080838" + "diskMBpsReadWrite": { + "value": 60 + }, + "diskSizeGB": { + "value": 128 + }, + "lock": { + "value": "CanNotDelete" + }, + "logicalSectorSize": { + "value": 512 + }, + "osType": { + "value": "Windows" + }, + "publicNetworkAccess": { + "value": "Enabled" }, "roleAssignments": { "value": [ { "principalIds": [ - "<>" + "" ], "roleDefinitionIdOrName": "Reader" } @@ -248,7 +273,7 @@ module disks './Microsoft.Compute/disks/deploy.bicep' = {

-

Example 2: Import

+

Example 2: Image

@@ -256,23 +281,22 @@ module disks './Microsoft.Compute/disks/deploy.bicep' = { ```bicep module disks './Microsoft.Compute/disks/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-Disks' + name: '${uniqueString(deployment().name, location)}-test-cdimg' params: { // Required parameters - name: '<>-az-disk-import-001' + name: '<>-cdimg001' sku: 'Standard_LRS' // Non-required parameters - createOption: 'Import' + createOption: 'FromImage' + imageReferenceId: '${subscription().id}/Providers/Microsoft.Compute/Locations/westeurope/Publishers/MicrosoftWindowsServer/ArtifactTypes/VMImage/Offers/WindowsServer/Skus/2016-Datacenter/Versions/14393.4906.2112080838' roleAssignments: [ { principalIds: [ - '<>' + '' ] roleDefinitionIdOrName: 'Reader' } ] - sourceUri: 'https://adp<>azsavhd001.blob.core.windows.net/vhds/adp-<>-az-imgt-vhd-001.vhd' - storageAccountId: '/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Storage/storageAccounts/adp<>azsavhd001' } } ``` @@ -291,30 +315,27 @@ module disks './Microsoft.Compute/disks/deploy.bicep' = { "parameters": { // Required parameters "name": { - "value": "<>-az-disk-import-001" + "value": "<>-cdimg001" }, "sku": { "value": "Standard_LRS" }, // Non-required parameters "createOption": { - "value": "Import" + "value": "FromImage" + }, + "imageReferenceId": { + "value": "${subscription().id}/Providers/Microsoft.Compute/Locations/westeurope/Publishers/MicrosoftWindowsServer/ArtifactTypes/VMImage/Offers/WindowsServer/Skus/2016-Datacenter/Versions/14393.4906.2112080838" }, "roleAssignments": { "value": [ { "principalIds": [ - "<>" + "" ], "roleDefinitionIdOrName": "Reader" } ] - }, - "sourceUri": { - "value": "https://adp<>azsavhd001.blob.core.windows.net/vhds/adp-<>-az-imgt-vhd-001.vhd" - }, - "storageAccountId": { - "value": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Storage/storageAccounts/adp<>azsavhd001" } } } @@ -323,7 +344,7 @@ module disks './Microsoft.Compute/disks/deploy.bicep' = {

-

Example 3: Min

+

Example 3: Import

@@ -331,21 +352,23 @@ module disks './Microsoft.Compute/disks/deploy.bicep' = { ```bicep module disks './Microsoft.Compute/disks/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-Disks' + name: '${uniqueString(deployment().name, location)}-test-cdimp' params: { // Required parameters - name: '<>-az-disk-min-001' + name: '<>-cdimp001' sku: 'Standard_LRS' // Non-required parameters - diskSizeGB: 1 + createOption: 'Import' roleAssignments: [ { principalIds: [ - '<>' + '' ] roleDefinitionIdOrName: 'Reader' } ] + sourceUri: '' + storageAccountId: '' } } ``` @@ -364,24 +387,30 @@ module disks './Microsoft.Compute/disks/deploy.bicep' = { "parameters": { // Required parameters "name": { - "value": "<>-az-disk-min-001" + "value": "<>-cdimp001" }, "sku": { "value": "Standard_LRS" }, // Non-required parameters - "diskSizeGB": { - "value": 1 + "createOption": { + "value": "Import" }, "roleAssignments": { "value": [ { "principalIds": [ - "<>" + "" ], "roleDefinitionIdOrName": "Reader" } ] + }, + "sourceUri": { + "value": "" + }, + "storageAccountId": { + "value": "" } } } @@ -390,7 +419,7 @@ module disks './Microsoft.Compute/disks/deploy.bicep' = {

-

Example 4: Parameters

+

Example 4: Min

@@ -398,27 +427,13 @@ module disks './Microsoft.Compute/disks/deploy.bicep' = { ```bicep module disks './Microsoft.Compute/disks/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-Disks' + name: '${uniqueString(deployment().name, location)}-test-cdmin' params: { // Required parameters - name: '<>-az-disk-x-001' - sku: 'UltraSSD_LRS' + name: '<>-cdmin001' + sku: 'Standard_LRS' // Non-required parameters - diskIOPSReadWrite: 500 - diskMBpsReadWrite: 60 - diskSizeGB: 128 - lock: 'CanNotDelete' - logicalSectorSize: 512 - osType: 'Windows' - publicNetworkAccess: 'Enabled' - roleAssignments: [ - { - principalIds: [ - '<>' - ] - roleDefinitionIdOrName: 'Reader' - } - ] + diskSizeGB: 1 } } ``` @@ -437,42 +452,14 @@ module disks './Microsoft.Compute/disks/deploy.bicep' = { "parameters": { // Required parameters "name": { - "value": "<>-az-disk-x-001" + "value": "<>-cdmin001" }, "sku": { - "value": "UltraSSD_LRS" + "value": "Standard_LRS" }, // Non-required parameters - "diskIOPSReadWrite": { - "value": 500 - }, - "diskMBpsReadWrite": { - "value": 60 - }, "diskSizeGB": { - "value": 128 - }, - "lock": { - "value": "CanNotDelete" - }, - "logicalSectorSize": { - "value": 512 - }, - "osType": { - "value": "Windows" - }, - "publicNetworkAccess": { - "value": "Enabled" - }, - "roleAssignments": { - "value": [ - { - "principalIds": [ - "<>" - ], - "roleDefinitionIdOrName": "Reader" - } - ] + "value": 1 } } } From 8ef877410b3173874e923edc050739d41fc1b272 Mon Sep 17 00:00:00 2001 From: Erika Gressi Date: Wed, 19 Oct 2022 20:15:32 +0200 Subject: [PATCH 10/10] static validation back --- .github/workflows/ms.compute.disks.yml | 36 +++++++++++++------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ms.compute.disks.yml b/.github/workflows/ms.compute.disks.yml index 010fd2ae7f..69e09d3dbe 100644 --- a/.github/workflows/ms.compute.disks.yml +++ b/.github/workflows/ms.compute.disks.yml @@ -63,23 +63,23 @@ jobs: ######################### # Static validation # ######################### - # job_module_pester_validation: - # runs-on: ubuntu-20.04 - # name: 'Static validation' - # steps: - # - name: 'Checkout' - # uses: actions/checkout@v2 - # with: - # fetch-depth: 0 - # - name: Set environment variables - # uses: ./.github/actions/templates/setEnvironmentVariables - # with: - # variablesPath: ${{ env.variablesPath }} - # - name: 'Run tests' - # uses: ./.github/actions/templates/validateModulePester - # with: - # modulePath: '${{ env.modulePath }}' - # moduleTestFilePath: '${{ env.moduleTestFilePath }}' + job_module_pester_validation: + runs-on: ubuntu-20.04 + name: 'Static validation' + steps: + - name: 'Checkout' + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set environment variables + uses: ./.github/actions/templates/setEnvironmentVariables + with: + variablesPath: ${{ env.variablesPath }} + - name: 'Run tests' + uses: ./.github/actions/templates/validateModulePester + with: + modulePath: '${{ env.modulePath }}' + moduleTestFilePath: '${{ env.moduleTestFilePath }}' ############################# # Deployment validation # @@ -89,7 +89,7 @@ jobs: name: 'Deployment validation' needs: - job_initialize_pipeline - # - job_module_pester_validation + - job_module_pester_validation strategy: fail-fast: false matrix: