I have an image in my Azure Shared Image Gallery (myGallery
) named myImage
and version 1.0.0
.
I am attempting to create a Virtual Machine via Terraform for this image in the gallery and am receiving the following error:
Error: creating Linux Virtual Machine "testingvm" (Resource Group "myrg"): compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: Code="InvalidParameter" Message="Parameter 'osProfile' is not allowed." Target="osProfile"
- Azure CLI Version: 2.26.1
- Terraform Version: 1.0.0
- Azure Terraform Provider Version: 2.69.0
My Terraform for the Virtual Machine looks like this:
resource "azurerm_linux_virtual_machine" "testingvm" {
name = "testingvm"
resource_group_name = var.resource_group_name
location = var.location
size = "Standard_D2s_v4"
network_interface_ids = [azurerm_network_interface.testingvm.id]
admin_username = "azureuser"
source_image_id = "/subscriptions/MY_SUBSCRIPTION/resourceGroups/myrg/providers/Microsoft.Compute/galleries/myGallery/images/myImage/versions/1.0.0"
os_disk {
name = "testingvm-os"
caching = "ReadWrite"
storage_account_type = "Premium_LRS"
}
admin_ssh_key {
username = "azureuser"
public_key = module.vm_key_pair.pair_key_pub_value_openssh
}
}
I tried this using both of these with no luck (I believe the latter is what is recommended):
I tried referencing this Stack Overflow entry without any luck as well.
What am I doing wrong here?
Another Attempt
I also tried using this:
source_image_reference {
publisher = "myPublisher"
offer = "myOffer"
sku = "mySKU"
version = "1.0.0"
}
After viewing the output of this, where the identifier
block spits out matching parameters:
az sig image-definition show \
--gallery-image-definition myImage \
--gallery-name myGallery
--resource-group myrg
That results in:
Error: creating Linux Virtual Machine "testingvm" (Resource Group "myrg"): compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: Code="PlatformImageNotFound" Message="The platform image 'myPublisher:myOffer:mySKU:1.0.0' is not available. Verify that all fields in the storage profile are correct. For more details about storage profile information, please refer to https://aka.ms/storageprofile" Target="imageReference"