hey Jan Claes,
this error is not a generic bicep issue, it is the marketplace backend telling u that the URN microsoftwindowsdesktop:office-365:win11-24h2-avd-m365 simply does not exist or is not available in the context Azure Local is using. The key point is that Azure Local marketplaceGalleryImages does not use the full public Azure Marketplace catalog the same way Azure VMs do. Only a subset of images is replicated and supported for Azure Local and Azure Stack HCI scenarios. If the offer sku combo is valid for Azure VM but not published to Azure Local, the edge marketplace service returns NotFound and token generation fails.
Look is whether that exact URN is available in ur region for Azure Local. Do not assume that because it works for az vm image list it will work for Microsoft.AzureStackHCI marketplaceGalleryImages. Use Azure CLI to list images for Azure Local specifically, for example:
az stack-hci-vm image list --location westeurope
or in the Azure portal under Azure Local marketplace gallery images to see the exact publisher offer sku version values that are actually supported.
Is that the skuVersion u pass matches a version that exists for Azure Local. In many cases version latest is not supported for Azure Local and u must provide an explicit version string that exists in the local catalog.
is region mismatch? In ur bicep u hardcoded location westeurope. Azure Local images are region scoped and tied to the customLocation. Make sure the customLocation and the image location align with a region where that image is actually published for Azure Local. If the image is not replicated to westeurope for Azure Local, u will get NotFound even though it exists in global Azure.
And check the exact offer name. For many Windows 11 AVD M365 images the offer is actually windows-11 or windows-11-avd rather than office-365. The offer office-365 is commonly used in VM context but not always in Azure Local context. If the backend cannot resolve the URN exactly as publisher:offer:sku, SAS generation fails.
Actually this is almost always one of three things like the URN is valid for Azure VM but not Azure Local, the version does not exist in Azure Local, or the region does not have that image replicated. The fix is to list and use only the images explicitly available for Azure Local in that region and custom location rather than reusing a public Azure VM URN.
rgds,
Alex