Azure / Azure/azure-powershell

How does one launch a VM from a Community Gallery ?

Open
#28,448 5 comments 1 reaction 1 assignee Claimed by @sandeepraichura View on GitHub
Compute - Images question Service Attention
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
2d 17h
Merged PRs (30d)
51

Description

### Discussed in https://github.com/Azure/azure-powershell/discussions/28404

Originally posted by **mfortin** August 18, 2025
I can launch VM using New-AzVM cmdlets from a SharedGallery, a legacy image or from the marketplace, however I can't figure how to launch a VM from a Community Gallery.

Fort instance this image: `/CommunityGalleries/rocky-dc1c6aa6-905b-4d9c-9577-63ccc28c482a/Images/Rocky-9-x86_64/Versions/9.4.20240509`

I am getting the following stack trace:
```
Microsoft.Azure.Commands.Compute.Common.ComputeCloudException: Property id '/CommunityGalleries/rocky-dc1c6aa6-905b-4d9c-9577-63ccc28c482a/Images/Rocky-9-x86_64/Versions/9.4.20240509' at path 'properties.storageProfile.imageReference.id' is invalid. Expect fully qualified resource Id that start with '/subscriptions/{subscriptionId}' or '/providers/{resourceProviderNamespace}/'.
ErrorCode: LinkedInvalidPropertyId
ErrorMessage: Property id '/CommunityGalleries/rocky-dc1c6aa6-905b-4d9c-9577-63ccc28c482a/Images/Rocky-9-x86_64/Versions/9.4.20240509' at path 'properties.storageProfile.imageReference.id' is invalid. Expect fully qualified resource Id that start with '/subscriptions/{subscriptionId}' or '/providers/{resourceProviderNamespace}/'.
ErrorTarget:
StatusCode: 400
ReasonPhrase: Bad Request
OperationID : 4215044a-45df-45fd-8087-46518e025d5b
---> Microsoft.Rest.Azure.CloudException: Property id '/CommunityGalleries/rocky-dc1c6aa6-905b-4d9c-9577-63ccc28c482a/Images/Rocky-9-x86_64/Versions/9.4.20240509' at path 'properties.storageProfile.imageReference.id' is invalid. Expect fully qualified resource Id that start with '/subscriptions/{subscriptionId}' or '/providers/{resourceProviderNamespace}/'.
at Microsoft.Azure.Commands.Compute.NewAzureVMCommand.<>c__DisplayClass259_0.b__0()
at Microsoft.Azure.Commands.Compute.ComputeClientBaseCmdlet.ExecuteClientAction(Action action)
--- End of inner exception stack trace ---
at Microsoft.Azure.Commands.Compute.ComputeClientBaseCmdlet.ExecuteClientAction(Action action)
at Microsoft.Azure.Commands.Compute.NewAzureVMCommand.DefaultExecuteCmdlet()
at Microsoft.Azure.Commands.Compute.NewAzureVMCommand.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
System.Management.Automation.InvocationInfo
```

I tried with:
```
$VmConfig = New-AzVMConfig -VMName "${ImageName}" -VMSize "${InstanceType}" -ImageReferenceId ${ImageId}
```
and I also tried
````
Set-AzVMSourceImage -VM $VmConfig -Id ${ImageId}
```

What am I doing wrong ?

Using pwsh 7.5.2, Az 14.3.0, Az.Compute 10.2.0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.