Azure VM not being deployed using Terraform

Wacar Hussain 21 Reputation points
2024-04-24T07:03:32.5733333+00:00

Hi

I am having issues creating a VM using Terraform its windows server 2022 the error I am getting is the below message

compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="ResourcePurchaseValidationFailed" Message="User failed validation to purchase resources. Error message: 'The offer with Offer ID 'Microsoft' was not found. Try one of these: 1- Make sure the offer name is written correctly. 2- If this offer was recently created, allow up to 30 minutes for it to be available for purchase. 3- The offer may have been removed from the marketplace. Look for similar offers from this publisher here: 'https://azuremarketplace.microsoft.com/en-us/marketplace/apps?page=1%26search=MicrosoftWindowsServer%20Microsoft'. Publisher ID: 'MicrosoftWindowsServer', Offer ID: 'Microsoft', Correlation ID '0ecfb036-612b-c3dc-7c77-0e73d182b8e7'.'"

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,160 questions
0 comments No comments
{count} votes

Accepted answer
  1. Alex Burlachenko 810 Reputation points
    2024-04-24T07:56:09.7666667+00:00

    The physical location of your company's data in Azure will depend on the region you selected when creating your resources. Azure ensures that your data is stored within the chosen geography. This means that if you have selected a region within your country, and Azure has a data center in that region, it is safe to assume that your data will be stored in your country.

    The error message you are seeing typically occurs when Azure Marketplace cannot find the offer ID that you are trying to use. In this case, the offer ID "Microsoft" seems to be missing.

    Here are some steps you can try to resolve this issue:

    1. Check the Offer ID - Ensure that the offer ID is correct. The offer ID must match exactly with what is available in the Azure Marketplace.
    2. Wait for the Offer to Be Available - If the offer has recently been created, it may take up to 30 minutes for the offer to become available for purchase.Check if the Offer has Been Removed: If the offer has been removed from the marketplace, you can try looking for similar offers from the same publisher. Additionally, when creating a Windows Server 2022 VM with Terraform on Azure, there is one extra step you need to take before creating the VM. Before creating the VM, you need to run a Terraform import command with your Azure tenant ID. Here is the command:
    terraform import azurerm_marketplace_agreement.microsoftwindowsserver /subscriptions/YOUR-AZURE-SUBSCRIPTION-ID/providers/Microsoft.MarketplaceOrdering/agreements/microsoftwindowsserver/offers/microsoftserveroperatingsystems-previews/plans/windows-server-2022
    
    

    Once you run the above command, you can proceed with your VM creation.

    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members. 

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anand Prakash Yadav 6,085 Reputation points Microsoft Vendor
    2024-04-24T10:44:43.13+00:00

    Hello Wacar Hussain,

    Thank you for posting your query here!

    The error message you’re seeing, ResourcePurchaseValidationFailed, typically occurs when there’s an issue with the Azure Marketplace offer ID that’s being used in your Terraform configuration.

    · The error message suggests that the offer with Offer ID ‘Microsoft’ was not found. Make sure the offer name is written correctly. You might want to verify the correct Offer ID for the Windows Server 2022 image in the Azure Marketplace. https://stackoverflow.com/questions/37828508/resourcepurchasevalidationfailed-when-creating-a-vm-via-azure-rm-rest-api

    · If you’re including a plan block in your Terraform configuration, try removing it. Sometimes, including a plan block can cause the system to attempt to purchase something that doesn’t exist.

    · If you’re trying to deploy a resource that requires additional legal and purchasing terms acceptance, you might need to use Set-AzureRmMarketplaceTerms before deployment.
    https://stackoverflow.com/questions/60284654/resourcepurchasevalidationfailed-error-while-creating-azure-pipeline

    · If the offer was recently created, it might take up to 30 minutes for it to be available for purchase.

    I hope this helps! Please let me know if the issue persists or if you have any other questions.

    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members. 

    0 comments No comments