Hi am trying to create a VM using Azure RM REST APIs, but It gives the following error code
"error": {
"code": "ResourcePurchaseValidationFailed",
"message": "User failed validation to purchase resources. Error message: 'Offer with PublisherId: Microsoft and OfferId: Windows Server 2008 R2 SP1 not found in Azure Data Market. If this offer has been created recently, please allow upto 30 minutes for this offer to be available for Purchase.'"
}
}
Has anyone ever faced such kind of problem?
As I understood it is related with PublisherId & OfferId in Azure Data Market. Please help me how can I get this PublisherId & OfferId from Azure Data Market for my subscription.
This could happen if you are including plan information in the request. By adding this, it is forcing the system to purchase something that does not exist. This can be verified by using the below powershell command:
$pubName = 'MicrosoftWindowsServer'
$offerName = 'WindowsServer'
$skuName = '2016-Datacenter'
$version = '2016.127.20180315'
Get-AzureRMVMImage -Location westeurope -Publisher $pubName -Offer $offerName -Skus $skuName -Version $version
As you can see the output shows that plan information are not needed through the PurchasePlan property:
Id : /Subscriptions/5e747971-92b4-41ac-963a-188c55951695/Providers/Microsoft.Compute/Locations/westeurope/Publishers/MicrosoftWindowsServer/ArtifactTypes/V
MImage/Offers/WindowsServer/Skus/2016-Datacenter/Versions/2016.127.20180315
Location : westeurope
PublisherName : MicrosoftWindowsServer
Offer : WindowsServer
Skus : 2016-Datacenter
Version : 2016.127.20180315
FilterExpression :
Name : 2016.127.20180315
OSDiskImage : {
"operatingSystem": "Windows"
}
PurchasePlan : null
DataDiskImages : []
If you are trying to make that script deploy VMs that may or may not need a PurchasePlan alike, you can use the below approach in your script :
Get the latest version number of the image :
$AzureImageSku = Get-AzureRmVMImage -Location westeurope -PublisherName "MicrosoftWindowsServer" ` -Offer "WindowsServer" -Skus "2016-Datacenter" $AzureImageSku = $AzureImageSku | Sort-Object Version -Descending #put the newest first $AzureImageSku[0] #Newest2016-Datacenter
Check if a plan is needed using Get-AzureRmImage cmdlet