-
Notifications
You must be signed in to change notification settings - Fork 437
[Modules] Images - Proposal for a slightly different structure #2136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
eriqua
merged 5 commits into
users/erikag/1921-images-newdep
from
users/erikag/1921-images-newdep_alsehrTest
Sep 30, 2022
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
152 changes: 152 additions & 0 deletions
152
modules/Microsoft.Compute/images/.test/common/dependencies.bicep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,152 @@ | ||
| @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.') | ||
| 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 | ||
|
|
||
| @description('Required. The name of the destination Storage Account to copy the created VHD to.') | ||
| param destinationStorageAccountName 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: '${uniqueString(deployment().name, location)}-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 \\"${destinationStorageAccountName}\\" -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://${destinationStorageAccountName}.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 |
40 changes: 0 additions & 40 deletions
40
modules/Microsoft.Compute/images/.test/common/dependencies01.bicep
This file was deleted.
Oops, something went wrong.
105 changes: 0 additions & 105 deletions
105
modules/Microsoft.Compute/images/.test/common/dependencies02.bicep
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
modules/Microsoft.Compute/images/.test/common/dependencies_rbac.bicep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| targetScope = 'subscription' | ||
|
|
||
| param managedIdentityResourceId string | ||
| 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' | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.