Can't create VM from image standard security type in Azure in runbooks

Julien Sénéchal 6 Reputation points
2024-01-10T12:48:21.63+00:00

Hello,

I've created a runbook that manages my machines automatically and deploys them via a managed image.
During the development, I had a problem during my scripting because my master machines were in TrustedLaunched SecurityType. So I recreated an image with Standard SecurityType and my script worked perfectly.

When I run the same script from the Runbook, the error comes back, but this time for Standard.
For me, it has no sense and i can't find any documentation about that problem.

Can you explain me the problem or give me a solution please ?

I tried to open a ticket on Github but Microsoft don't get back to me (https://github.com/Azure/azure-powershell/issues/23756)

Thank you in advance for your help

Issue script & Debug output

Write-Output "Creating VDI $tmpName..."
$nic = New-AzNetworkInterface -ResourceGroupName $rgName -Location $location -Name "$tmpName-NIC" -SubnetId (Get-AzVirtualNetwork -ResourceGroupName $rgName -Name $vnetName).Subnets[0].Id -NetworkSecurityGroupId (Get-AzResource -ResourceGroupName $rgName -Name $nsgName).ResourceId -Force
$tmpConfig = New-AzVMConfig -VMName "$tmpName-VM" -VMSize $masterVM.HardwareProfile.Vmsize -IdentityType "SystemAssigned"
$tmpConfig = Set-AzVMSecurityProfile -VM $tmpConfig -SecurityType "Standard"
$tmpConfig = Set-AzVMOSDisk -VM $tmpConfig -Name "$tmpName-OSDisk" -Windows -CreateOption "FromImage" 
$tmpConfig = Set-AzVMSourceImage -VM $tmpConfig -Id $masterImage.Id
$tmpConfig = Set-AzVMOperatingSystem -VM $tmpConfig -Windows -ComputerName $tmpName -Credential $creds
$tmpConfig = Set-AzVMBootDiagnostic -VM $tmpConfig -Disable
$tmpConfig = Add-AzVMNetworkInterface -VM $tmpConfig -Id $nic.Id
New-AzVM -VM $tmpConfig -ResourceGroupName $rgName -Location $location -Zone $masterVM.Zones


Error output

Error : {Managed Images are not supported for virtual machines with security type Standard.
                       ErrorCode: BadRequest
                       ErrorMessage: Managed Images are not supported for virtual machines with security type Standard.
                       ErrorTarget: 
                       StatusCode: 400
                       ReasonPhrase: 
                       OperationID: 76601d3d-d902-4b4f-b8fc-ab1f743c8f79}
Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
9,014 questions
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,366 questions
Windows for business Windows Server User experience PowerShell
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.