Azure Compute Version

This page shows how to write Terraform and Azure Resource Manager for Compute Version and write them securely.

azurerm_shared_image_version (Terraform)

The Version in Compute can be configured in Terraform with the resource name azurerm_shared_image_version. The following sections describe 7 examples of how to use the resource and its parameters.

Example Usage from GitHub

main.tf#L1
resource "azurerm_shared_image_version" "version" {
  count               = var.create ? 1 : 0
  name                = var.global_image_version
  gallery_name        = var.gallery_name
  image_name          = var.image_name
  resource_group_name = var.resource_group_name
announcing_terraform_4.tf#L18
resource "azurerm_shared_image_version" "ubuntu" {
  name                = "1.0.1"
  gallery_name        = azurerm_shared_image_gallery.image_gallery.name
  image_name          = azurerm_shared_image.image_definition.name
  resource_group_name = azurerm_resource_group.image_gallery.name
  location            = var.source_image_location
resource.tf#L17
resource "azurerm_shared_image_version" "siver" {
  name                = var.res_si_ver_name
  gallery_name        = var.res_sig_name
  image_name          = azurerm_shared_image.si.name
  resource_group_name = var.res_si_rg_name
  location            = var.res_location
main.tf#L1
resource "azurerm_shared_image_version" "example" {
  name                = var.name
  gallery_name        = data.azurerm_shared_image.existing.gallery_name
  image_name          = data.azurerm_shared_image.existing.name
  resource_group_name = data.azurerm_shared_image.existing.resource_group_name
  location            = data.azurerm_shared_image.existing.location
main.tf#L36
resource "azurerm_shared_image_version" "image_tr" {
  name                = "1.0.0"
  gallery_name        = azurerm_shared_image.image_tr.gallery_name
  image_name          = azurerm_shared_image.image_tr.name
  resource_group_name = azurerm_shared_image.image_tr.resource_group_name
  location            = azurerm_shared_image.image_tr.location
main.tf#L7
resource "azurerm_shared_image_version" "this" {
  exclude_from_latest = var.exclude_from_latest
  gallery_name        = var.gallery_name
  image_name          = var.image_name
  location            = var.location
  managed_image_id    = var.managed_image_id
main.tf#L7
resource "azurerm_shared_image_version" "this" {
  exclude_from_latest = var.exclude_from_latest
  gallery_name        = var.gallery_name
  image_name          = var.image_name
  location            = var.location
  managed_image_id    = var.managed_image_id

Review your Terraform file for Azure best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Manages a Version of a Shared Image within a Shared Image Gallery.

Tips: Best Practices for The Other Azure Compute Resources

In addition to the azurerm_linux_virtual_machine, Azure Compute has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.

risk-label

azurerm_linux_virtual_machine

Ensure to use SSH authentication for virtual machines

It is better to use SSH authentication for virtual machines instead of password authentication to enforce more secure ways.

risk-label

azurerm_managed_disk

Ensure to enable the encryption on managed disks

It is better to enable the encryption on managed disks.

risk-label

azurerm_virtual_machine

Ensure to use SSH authentication for virtual machines

It is better to use SSH authentication for virtual machines instead of password authentication to enforce more secure ways.

Review your Azure Compute settings

In addition to the above, there are other security points you should be aware of making sure that your .tf files are protected in Shisho Cloud.

Microsoft.Compute/galleries/images/versions (Azure Resource Manager)

The galleries/images/versions in Microsoft.Compute can be configured in Azure Resource Manager with the resource name Microsoft.Compute/galleries/images/versions. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

versions.json#L3
  "type": "Microsoft.Compute/galleries/images/versions",
  "apiVersion": "2019-03-01",
  "location": "string",
  "tags": {},
  "properties": {
    "publishingProfile": {
azuredeploy.json#L32
      "type": "Microsoft.Compute/galleries/images/versions",
      "name": "[concat(parameters('galleryName'), '/', parameters('galleryImageDefinitionName'), '/', parameters('galleryImageVersionName'))]",
      "apiVersion": "2018-06-01",
      "location": "[resourceGroup().location]",
      "properties": {
        "publishingProfile": {
azuredeploy.json#L32
      "type": "Microsoft.Compute/galleries/images/versions",
      "name": "[concat(parameters('galleryName'), '/', parameters('galleryImageDefinitionName'), '/', parameters('galleryImageVersionName'))]",
      "apiVersion": "2018-06-01",
      "location": "[resourceGroup().location]",
      "properties": {
        "publishingProfile": {
azureDeploy.json#L20
      "type": "Microsoft.Compute/galleries/images/versions",
      "name": "[variables('versionName')]",
      "apiVersion": "2018-06-01",
      "location": "[resourceGroup().location]",
      "properties": {
        "publishingProfile": {
azuredeploy.json#L32
      "type": "Microsoft.Compute/galleries/images/versions",
      "name": "[concat(parameters('galleryName'), '/', parameters('galleryImageDefinitionName'), '/', parameters('galleryImageVersionName'))]",
      "apiVersion": "2018-06-01",
      "location": "[resourceGroup().location]",
      "properties": {
        "publishingProfile": {
azuredeploy.json#L32
      "type": "Microsoft.Compute/galleries/images/versions",
      "name": "[concat(parameters('galleryName'), '/', parameters('galleryImageDefinitionName'), '/', parameters('galleryImageVersionName'))]",
      "apiVersion": "2018-06-01",
      "location": "[resourceGroup().location]",
      "properties": {
        "publishingProfile": {
azuredeploy.json#L32
      "type": "Microsoft.Compute/galleries/images/versions",
      "name": "[concat(parameters('galleryName'), '/', parameters('galleryImageDefinitionName'), '/', parameters('galleryImageVersionName'))]",
      "apiVersion": "2018-06-01",
      "location": "[resourceGroup().location]",
      "properties": {
        "publishingProfile": {
azuredeploy.json#L32
      "type": "Microsoft.Compute/galleries/images/versions",
      "name": "[concat(parameters('galleryName'), '/', parameters('galleryImageDefinitionName'), '/', parameters('galleryImageVersionName'))]",
      "apiVersion": "2018-06-01",
      "location": "[resourceGroup().location]",
      "properties": {
        "publishingProfile": {
azuredeploy.json#L32
      "type": "Microsoft.Compute/galleries/images/versions",
      "name": "[concat(parameters('galleryName'), '/', parameters('galleryImageDefinitionName'), '/', parameters('galleryImageVersionName'))]",
      "apiVersion": "2018-06-01",
      "location": "[resourceGroup().location]",
      "properties": {
        "publishingProfile": {
azuredeploy.json#L32
      "type": "Microsoft.Compute/galleries/images/versions",
      "name": "[concat(parameters('galleryName'), '/', parameters('galleryImageDefinitionName'), '/', parameters('galleryImageVersionName'))]",
      "apiVersion": "2018-06-01",
      "location": "[resourceGroup().location]",
      "properties": {
        "publishingProfile": {

Parameters

  • apiVersion required - string
  • location required - string

    Resource location

  • name required - string

    The name of the gallery image version to be created. Needs to follow semantic version name pattern: The allowed characters are digit and period. Digits must be within the range of a 32-bit integer. Format: <MajorVersion>.<MinorVersion>.<Patch>

  • properties required
      • publishingProfile optional
          • endOfLifeDate optional - string

            The end of life date of the gallery image version. This property can be used for decommissioning purposes. This property is updatable.

          • excludeFromLatest optional - boolean

            If set to true, Virtual Machines deployed from the latest version of the Image Definition won't use this Image Version.

          • replicaCount optional - integer

            The number of replicas of the Image Version to be created per region. This property would take effect for a region when regionalReplicaCount is not specified. This property is updatable.

          • replicationMode optional - string

            Optional parameter which specifies the mode to be used for replication. This property is not updatable.

          • storageAccountType optional - string

            Specifies the storage account type to be used to store the image. This property is not updatable.

          • targetRegions optional array
              • encryption optional
                  • dataDiskImages optional array
                      • diskEncryptionSetId optional - string

                        A relative URI containing the resource ID of the disk encryption set.

                      • lun required - integer

                        This property specifies the logical unit number of the data disk. This value is used to identify data disks within the Virtual Machine and therefore must be unique for each data disk attached to the Virtual Machine.

                  • osDiskImage optional
                      • diskEncryptionSetId optional - string

                        A relative URI containing the resource ID of the disk encryption set.

              • name required - string

                The name of the region.

              • regionalReplicaCount optional - integer

                The number of replicas of the Image Version to be created per region. This property is updatable.

              • storageAccountType optional - string

                Specifies the storage account type to be used to store the image. This property is not updatable.

      • storageProfile required
          • dataDiskImages optional array
              • hostCaching optional - string

                The host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite'.

              • lun required - integer

                This property specifies the logical unit number of the data disk. This value is used to identify data disks within the Virtual Machine and therefore must be unique for each data disk attached to the Virtual Machine.

              • source optional
                  • id optional - string

                    The id of the gallery artifact version source. Can specify a disk uri, snapshot uri, user image or storage account resource.

                  • uri optional - string

                    The uri of the gallery artifact version source. Currently used to specify vhd/blob source.

          • osDiskImage optional
              • hostCaching optional - string

                The host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite'.

              • source optional
                  • id optional - string

                    The id of the gallery artifact version source. Can specify a disk uri, snapshot uri, user image or storage account resource.

                  • uri optional - string

                    The uri of the gallery artifact version source. Currently used to specify vhd/blob source.

          • source optional
              • id optional - string

                The id of the gallery artifact version source. Can specify a disk uri, snapshot uri, user image or storage account resource.

              • uri optional - string

                The uri of the gallery artifact version source. Currently used to specify vhd/blob source.

  • tags optional - string

    Resource tags

  • type required - string

Frequently asked questions

What is Azure Compute Version?

Azure Compute Version is a resource for Compute of Microsoft Azure. Settings can be wrote in Terraform.

Where can I find the example code for the Azure Compute Version?

For Terraform, the rohrerb/terraform-eiac, raymondbutcher/pretf and avishekansible/AzureLandingZone source code examples are useful. See the Terraform Example section for further details.

For Azure Resource Manager, the da-edra/scraping-azure, jacksonhansen498/azure-quickstart-templates and ConsistentTheory/AzureRep source code examples are useful. See the Azure Resource Manager Example section for further details.