Skip to content
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

feat: Updated Virtual-Machine-Images AVM module references #3444

Merged
merged 8 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 67 additions & 40 deletions avm/ptn/virtual-machine-images/azure-image-builder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ This module provides you with a packaged solution to create custom images using
| :-- | :-- |
| `Microsoft.Authorization/locks` | [2020-05-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Authorization/2020-05-01/locks) |
| `Microsoft.Authorization/roleAssignments` | [2022-04-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Authorization/2022-04-01/roleAssignments) |
| `Microsoft.Compute/galleries` | [2022-03-03](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Compute/2022-03-03/galleries) |
| `Microsoft.Compute/galleries` | [2023-07-03](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Compute/2023-07-03/galleries) |
| `Microsoft.Compute/galleries/applications` | [2022-03-03](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Compute/2022-03-03/galleries/applications) |
| `Microsoft.Compute/galleries/images` | [2022-03-03](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Compute/2022-03-03/galleries/images) |
| `Microsoft.Compute/galleries/images` | [2023-07-03](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Compute/2023-07-03/galleries/images) |
| `Microsoft.Insights/diagnosticSettings` | [2021-05-01-preview](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Insights/2021-05-01-preview/diagnosticSettings) |
| `Microsoft.ManagedIdentity/userAssignedIdentities` | [2023-01-31](https://learn.microsoft.com/en-us/azure/templates/Microsoft.ManagedIdentity/2023-01-31/userAssignedIdentities) |
| `Microsoft.ManagedIdentity/userAssignedIdentities/federatedIdentityCredentials` | [2023-01-31](https://learn.microsoft.com/en-us/azure/templates/Microsoft.ManagedIdentity/2023-01-31/userAssignedIdentities/federatedIdentityCredentials) |
| `Microsoft.Network/privateEndpoints` | [2023-04-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2023-04-01/privateEndpoints) |
| `Microsoft.Network/privateEndpoints/privateDnsZoneGroups` | [2023-04-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2023-04-01/privateEndpoints/privateDnsZoneGroups) |
| `Microsoft.Network/virtualNetworks` | [2023-04-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2023-04-01/virtualNetworks) |
| `Microsoft.Network/virtualNetworks/subnets` | [2023-04-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2023-04-01/virtualNetworks/subnets) |
| `Microsoft.Network/virtualNetworks/virtualNetworkPeerings` | [2023-04-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2023-04-01/virtualNetworks/virtualNetworkPeerings) |
| `Microsoft.Network/virtualNetworks` | [2024-01-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/virtualNetworks) |
| `Microsoft.Network/virtualNetworks/subnets` | [2024-01-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/virtualNetworks/subnets) |
| `Microsoft.Network/virtualNetworks/virtualNetworkPeerings` | [2024-01-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/virtualNetworks/virtualNetworkPeerings) |
| `Microsoft.Resources/deploymentScripts` | [2023-08-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Resources/2023-08-01/deploymentScripts) |
| `Microsoft.Resources/resourceGroups` | [2024-03-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Resources/2024-03-01/resourceGroups) |
| `Microsoft.Storage/storageAccounts` | [2022-09-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Storage/2022-09-01/storageAccounts) |
Expand Down Expand Up @@ -77,11 +77,14 @@ module azureImageBuilder 'br/public:avm/ptn/virtual-machine-images/azure-image-b
computeGalleryImageDefinitions: [
{
hyperVGeneration: 'V2'
identifier: {
offer: 'devops_linux'
publisher: 'devops'
sku: 'devops_linux_az'
}
name: 'sid-linux'
offer: 'devops_linux'
osState: 'Generalized'
osType: 'Linux'
publisher: 'devops'
sku: 'devops_linux_az'
}
]
computeGalleryName: 'galapvmiaibmin'
Expand Down Expand Up @@ -121,11 +124,14 @@ module azureImageBuilder 'br/public:avm/ptn/virtual-machine-images/azure-image-b
"value": [
{
"hyperVGeneration": "V2",
"identifier": {
"offer": "devops_linux",
"publisher": "devops",
"sku": "devops_linux_az"
},
"name": "sid-linux",
"offer": "devops_linux",
"osType": "Linux",
"publisher": "devops",
"sku": "devops_linux_az"
"osState": "Generalized",
"osType": "Linux"
}
]
},
Expand Down Expand Up @@ -173,11 +179,14 @@ param computeGalleryImageDefinitionName = '<computeGalleryImageDefinitionName>'
param computeGalleryImageDefinitions = [
{
hyperVGeneration: 'V2'
identifier: {
offer: 'devops_linux'
publisher: 'devops'
sku: 'devops_linux_az'
}
name: 'sid-linux'
offer: 'devops_linux'
osState: 'Generalized'
osType: 'Linux'
publisher: 'devops'
sku: 'devops_linux_az'
}
]
param computeGalleryName = 'galapvmiaibmin'
Expand Down Expand Up @@ -216,11 +225,14 @@ module azureImageBuilder 'br/public:avm/ptn/virtual-machine-images/azure-image-b
computeGalleryImageDefinitions: [
{
hyperVGeneration: 'V2'
identifier: {
offer: 'devops_linux'
publisher: 'devops'
sku: 'devops_linux_az'
}
name: '<name>'
offer: 'devops_linux'
osState: 'Generalized'
osType: 'Linux'
publisher: 'devops'
sku: 'devops_linux_az'
}
]
computeGalleryName: 'galapvmiaiba'
Expand Down Expand Up @@ -291,11 +303,14 @@ module azureImageBuilder 'br/public:avm/ptn/virtual-machine-images/azure-image-b
"value": [
{
"hyperVGeneration": "V2",
"identifier": {
"offer": "devops_linux",
"publisher": "devops",
"sku": "devops_linux_az"
},
"name": "<name>",
"offer": "devops_linux",
"osType": "Linux",
"publisher": "devops",
"sku": "devops_linux_az"
"osState": "Generalized",
"osType": "Linux"
}
]
},
Expand Down Expand Up @@ -380,11 +395,14 @@ param computeGalleryImageDefinitionName = '<computeGalleryImageDefinitionName>'
param computeGalleryImageDefinitions = [
{
hyperVGeneration: 'V2'
identifier: {
offer: 'devops_linux'
publisher: 'devops'
sku: 'devops_linux_az'
}
name: '<name>'
offer: 'devops_linux'
osState: 'Generalized'
osType: 'Linux'
publisher: 'devops'
sku: 'devops_linux_az'
}
]
param computeGalleryName = 'galapvmiaiba'
Expand Down Expand Up @@ -649,11 +667,14 @@ module azureImageBuilder 'br/public:avm/ptn/virtual-machine-images/azure-image-b
computeGalleryImageDefinitions: [
{
hyperVGeneration: 'V2'
identifier: {
offer: 'devops_linux'
publisher: 'devops'
sku: 'devops_linux_az'
}
name: '<name>'
offer: 'devops_linux'
osState: 'Generalized'
osType: 'Linux'
publisher: 'devops'
sku: 'devops_linux_az'
}
]
computeGalleryName: 'galapvmiaibob'
Expand Down Expand Up @@ -694,11 +715,14 @@ module azureImageBuilder 'br/public:avm/ptn/virtual-machine-images/azure-image-b
"value": [
{
"hyperVGeneration": "V2",
"identifier": {
"offer": "devops_linux",
"publisher": "devops",
"sku": "devops_linux_az"
},
"name": "<name>",
"offer": "devops_linux",
"osType": "Linux",
"publisher": "devops",
"sku": "devops_linux_az"
"osState": "Generalized",
"osType": "Linux"
}
]
},
Expand Down Expand Up @@ -749,11 +773,14 @@ param computeGalleryImageDefinitionName = '<computeGalleryImageDefinitionName>'
param computeGalleryImageDefinitions = [
{
hyperVGeneration: 'V2'
identifier: {
offer: 'devops_linux'
publisher: 'devops'
sku: 'devops_linux_az'
}
name: '<name>'
offer: 'devops_linux'
osState: 'Generalized'
osType: 'Linux'
publisher: 'devops'
sku: 'devops_linux_az'
}
]
param computeGalleryName = 'galapvmiaibob'
Expand Down Expand Up @@ -1259,12 +1286,12 @@ This section gives you an overview of all local-referenced module files (i.e., o

| Reference | Type |
| :-- | :-- |
| `br/public:avm/res/compute/gallery:0.4.0` | Remote reference |
| `br/public:avm/res/managed-identity/user-assigned-identity:0.2.2` | Remote reference |
| `br/public:avm/res/network/virtual-network:0.1.6` | Remote reference |
| `br/public:avm/res/resources/deployment-script:0.3.1` | Remote reference |
| `br/public:avm/res/compute/gallery:0.7.0` | Remote reference |
| `br/public:avm/res/managed-identity/user-assigned-identity:0.4.0` | Remote reference |
| `br/public:avm/res/network/virtual-network:0.4.0` | Remote reference |
| `br/public:avm/res/resources/deployment-script:0.4.0` | Remote reference |
| `br/public:avm/res/storage/storage-account:0.9.1` | Remote reference |
| `br/public:avm/res/virtual-machine-images/image-template:0.3.1` | Remote reference |
| `br/public:avm/res/virtual-machine-images/image-template:0.4.0` | Remote reference |

## Notes

Expand Down
43 changes: 12 additions & 31 deletions avm/ptn/virtual-machine-images/azure-image-builder/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ resource imageTemplateRg 'Microsoft.Resources/resourceGroups@2024-03-01' = if (d
}

// User Assigned Identity (MSI)
module dsMsi 'br/public:avm/res/managed-identity/user-assigned-identity:0.2.2' = if (deploymentsToPerform == 'All' || deploymentsToPerform == 'Only base') {
module dsMsi 'br/public:avm/res/managed-identity/user-assigned-identity:0.4.0' = if (deploymentsToPerform == 'All' || deploymentsToPerform == 'Only base') {
name: '${deployment().name}-ds-msi'
scope: rg
params: {
Expand All @@ -174,7 +174,7 @@ module dsMsi 'br/public:avm/res/managed-identity/user-assigned-identity:0.2.2' =
}
}

module imageMSI 'br/public:avm/res/managed-identity/user-assigned-identity:0.2.2' = if (deploymentsToPerform == 'All' || deploymentsToPerform == 'Only base') {
module imageMSI 'br/public:avm/res/managed-identity/user-assigned-identity:0.4.0' = if (deploymentsToPerform == 'All' || deploymentsToPerform == 'Only base') {
name: '${deployment().name}-image-msi'
scope: rg
params: {
Expand All @@ -186,7 +186,6 @@ module imageMSI 'br/public:avm/res/managed-identity/user-assigned-identity:0.2.2

// MSI Subscription contributor assignment
resource imageMSI_rbac 'Microsoft.Authorization/roleAssignments@2022-04-01' = if (deploymentsToPerform == 'All' || deploymentsToPerform == 'Only base') {
// name: guid(subscription().subscriptionId, imageManagedIdentityName, contributorRole.id)
name: guid(
subscription().id,
'${subscription().id}/resourceGroups/${resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/${imageManagedIdentityName}',
Expand All @@ -203,7 +202,7 @@ resource imageMSI_rbac 'Microsoft.Authorization/roleAssignments@2022-04-01' = if
}

// Azure Compute Gallery
module azureComputeGallery 'br/public:avm/res/compute/gallery:0.4.0' = if (deploymentsToPerform == 'All' || deploymentsToPerform == 'Only base') {
module azureComputeGallery 'br/public:avm/res/compute/gallery:0.7.0' = if (deploymentsToPerform == 'All' || deploymentsToPerform == 'Only base') {
name: '${deployment().name}-acg'
scope: rg
params: {
Expand All @@ -215,7 +214,7 @@ module azureComputeGallery 'br/public:avm/res/compute/gallery:0.4.0' = if (deplo
}

// Image Template Virtual Network
module vnet 'br/public:avm/res/network/virtual-network:0.1.6' = if (deploymentsToPerform == 'All' || deploymentsToPerform == 'Only base') {
module vnet 'br/public:avm/res/network/virtual-network:0.4.0' = if (deploymentsToPerform == 'All' || deploymentsToPerform == 'Only base') {
name: '${deployment().name}-vnet'
scope: rg
params: {
Expand All @@ -229,28 +228,17 @@ module vnet 'br/public:avm/res/network/virtual-network:0.1.6' = if (deploymentsT
addressPrefix: virtualNetworkSubnetAddressPrefix
privateLinkServiceNetworkPolicies: 'Disabled' // Required if using Azure Image Builder with existing VNET
serviceEndpoints: [
{
service: 'Microsoft.Storage'
}
'Microsoft.Storage'
]
}
{
name: deploymentScriptSubnetName
addressPrefix: virtualNetworkDeploymentScriptSubnetAddressPrefix
privateLinkServiceNetworkPolicies: 'Disabled' // Required if using Azure Image Builder with existing VNET - temp
serviceEndpoints: [
{
service: 'Microsoft.Storage'
}
]
delegations: [
{
name: 'Microsoft.ContainerInstance.containerGroups'
properties: {
serviceName: 'Microsoft.ContainerInstance/containerGroups'
}
}
'Microsoft.Storage'
]
delegation: 'Microsoft.ContainerInstance/containerGroups'
}
]
location: location
Expand Down Expand Up @@ -363,7 +351,7 @@ module dsStorageAccount 'br/public:avm/res/storage/storage-account:0.9.1' = if (
// ============================== //

// Upload storage account files
module storageAccount_upload 'br/public:avm/res/resources/deployment-script:0.3.1' = if (deploymentsToPerform == 'All' || deploymentsToPerform == 'Only base' || deploymentsToPerform == 'Only assets & image') {
module storageAccount_upload 'br/public:avm/res/resources/deployment-script:0.4.0' = if (deploymentsToPerform == 'All' || deploymentsToPerform == 'Only base' || deploymentsToPerform == 'Only assets & image') {
name: '${deployment().name}-storage-upload-ds'
scope: resourceGroup(resourceGroupName)
params: {
Expand All @@ -382,13 +370,6 @@ module storageAccount_upload 'br/public:avm/res/resources/deployment-script:0.3.
]
}
scriptContent: loadTextContent('../../../utilities/e2e-template-assets/scripts/Set-StorageContainerContentByEnvVar.ps1')
// environmentVariables: [
// map(range(0, length(storageAccountFilesToUpload ?? [])), index => {
// name: '__SCRIPT__${storageAccountFilesToUpload![index].name}'
// value: storageAccountFilesToUpload![index].?value
// secureValue: storageAccountFilesToUpload![index].?secureValue
// })
// ]
environmentVariables: map(storageAccountFilesToUpload ?? [], file => {
name: '__SCRIPT__${replace(replace(file.name, '-', '__'), '.', '_') }' // May only be alphanumeric characters & underscores. The upload will replace '_' with '.' and '__' with '-'. E.g., Install__LinuxPowerShell_sh will be Install-LinuxPowerShell.sh
value: file.?value
Expand Down Expand Up @@ -438,7 +419,7 @@ resource dsMsi_existing 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-0
scope: resourceGroup(resourceGroupName)
}

module imageTemplate 'br/public:avm/res/virtual-machine-images/image-template:0.3.1' = if (deploymentsToPerform == 'All' || deploymentsToPerform == 'Only assets & image' || deploymentsToPerform == 'Only image') {
module imageTemplate 'br/public:avm/res/virtual-machine-images/image-template:0.4.0' = if (deploymentsToPerform == 'All' || deploymentsToPerform == 'Only assets & image' || deploymentsToPerform == 'Only image') {
name: '${deployment().name}-it'
scope: resourceGroup(resourceGroupName)
params: {
Expand Down Expand Up @@ -501,7 +482,7 @@ module imageTemplate 'br/public:avm/res/virtual-machine-images/image-template:0.
}

// Deployment script to trigger image build
module imageTemplate_trigger 'br/public:avm/res/resources/deployment-script:0.3.1' = if (deploymentsToPerform == 'All' || deploymentsToPerform == 'Only assets & image' || deploymentsToPerform == 'Only image') {
module imageTemplate_trigger 'br/public:avm/res/resources/deployment-script:0.4.0' = if (deploymentsToPerform == 'All' || deploymentsToPerform == 'Only assets & image' || deploymentsToPerform == 'Only image') {
name: '${deployment().name}-imageTemplate-trigger-ds'
scope: resourceGroup(resourceGroupName)
params: {
Expand Down Expand Up @@ -555,7 +536,7 @@ module imageTemplate_trigger 'br/public:avm/res/resources/deployment-script:0.3.
]
}

module imageTemplate_wait 'br/public:avm/res/resources/deployment-script:0.3.1' = if (waitForImageBuild && (deploymentsToPerform == 'All' || deploymentsToPerform == 'Only assets & image' || deploymentsToPerform == 'Only image')) {
module imageTemplate_wait 'br/public:avm/res/resources/deployment-script:0.4.0' = if (waitForImageBuild && (deploymentsToPerform == 'All' || deploymentsToPerform == 'Only assets & image' || deploymentsToPerform == 'Only image')) {
name: '${deployment().name}-imageTemplate-wait-ds'
scope: resourceGroup(resourceGroupName)
params: {
Expand Down Expand Up @@ -611,7 +592,7 @@ module imageTemplate_wait 'br/public:avm/res/resources/deployment-script:0.3.1'
// =============== //
// Definitions //
// =============== //

@export()
type storageAccountFilesToUploadType = {
@description('Required. The name of the environment variable.')
name: string
Expand Down
Loading