I have an issue creating a VM on Azure using Terraform.
We have a policy restricting from creating certain vm sizes for our subscription, but we created an exemption for a specific ResourceGroup.
I can create VM with the wanted size using my ServicePrincipal and with the following command:
$ az login --service-principal -u ... -p ... --tenant ...
$ az vm create --resource-group ... --name ... --image ... --admin-username ... --generate-ssh-keys --location ... --size ...
The VM is created successfully with the wanted size.
But, when I try to create the VM using Terraform, with the same VM size, I'm getting the following error:
level=error msg=Error: creating Linux Virtual Machine "..." (Resource Group "..."): compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: autorest/azure: Service returned an error. Status= Code="SkuNotAvailable" Message="The requested size for resource '/subscriptions/.../resourceGroups/.../providers/Microsoft.Compute/virtualMachines/...' is currently not available in location '...' zones '...' for subscription '...'. Please try another size or deploy to a different location or zones. See https://aka.ms/azureskunotavailable for details."
After running
az vm list-skus --location ... --size ... --all --output table
The output for the wanted size is:
restrictions
---
NotAvailableForSubscription, type: Zone, locations: ..., zones: 1,2,3
It looks like the size is unavailable, but using the CLI or Azure portal, I'm able to create VM with this size.
The terraform is running with the same service principal as the CLI command, in the same subscription, tenant and resource group.
Do you have an idea what can cause this problem creating the VM using terraform?
Thanks

