Not able to generalize a VM for creating a image out of the VM. #6700
-
Bicep version Describe the bug To Reproduce Additional context |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Please consider look into Azure Image Builder for an automated process to build images. https://docs.microsoft.com/en-us/azure/virtual-machines/image-builder-overview
There are multiple ways to manage this process, including via bicep. step 1 - create a gallery "ImageGalleryInfo": [
{
"Name": "01",
"description": "my image gallery"
}
], resource gallery 'Microsoft.Compute/galleries@2021-07-01' = [for (gallery,index) in ImageGalleryInfo : if(imgGallery[index].match) {
name: '${DeploymentURI}gallery${gallery.Name}'
location: resourceGroup().location
properties: {
// sharingProfile: {
// permissions: 'Private'
// }
description: gallery.description
identifier: {}
}
}] https://github.com/brwilkinson/AzureDeploymentFramework/blob/main/ADF/bicep/ImageGallery.bicep step 2 - leverage image builder for the images and imagetemplates "ImageInfo": [
{
"imageName": "vmss2019webnetcore5",
"GalleryName": "01",
"description": "vmss windows 2019 web server .Net Core",
"osType": "Windows",
"identifier": {
"offer": "WindowsServer",
"sku": "Win2019",
"role": "IMG5"
}
}
],
// current locations https://docs.microsoft.com/en-us/azure/virtual-machines/linux/image-builder-json#location
"imageTemplatesInfo": [
{
"imageName": "vmss2019webnetcore5",
"galleryName": "01",
"vmSize": "Standard_D4s_v3",
"osDiskSizeGB": 127,
"ibLocation": "WestCentralUS",
"deployTimeoutmin": 360,
"deployOnce": 1,
"buildNow": 1,
"PublishNow": 0
}
] resource Gallery 'Microsoft.Compute/galleries@2021-07-01' existing = [for (img,index) in ImageInfo : {
name: '${DeploymentURI}gallery${img.GalleryName}'
}]
resource IMG 'Microsoft.Compute/galleries/images@2021-07-01' = [for (img,index) in ImageInfo : {
name: image[index].imageName
parent: Gallery[index]
location: resourceGroup().location
properties: {
description: img.imageName
osType: OSType[img.OSType].OS
osState: 'Generalized'
hyperVGeneration: contains(OSType[img.OSType].imageReference.sku,'g2') ? 'V2' : 'V1'
identifier: {
publisher: '${DeploymentURI}_${image[index].imageName}'
offer: OSType[img.OSType].imagereference.offer
sku: OSType[img.OSType].imagereference.sku
}
}
}] https://github.com/brwilkinson/AzureDeploymentFramework/blob/main/ADF/bicep/ImageBuilder.bicep This is a Azure Tool, based on packer, you can customize your images in many ways e.g. https://github.com/brwilkinson/AzureDeploymentFramework/blob/main/ADF/bicep/ImageBuilder.bicep#L108 |
Beta Was this translation helpful? Give feedback.
-
@brwilkinson Thank you so much for pointing me to right direction. |
Beta Was this translation helpful? Give feedback.
Please consider look into Azure Image Builder for an automated process to build images.
https://docs.microsoft.com/en-us/azure/virtual-machines/image-builder-overview
There are multiple ways to manage this process, including via bicep.
step 1 - create a gallery