<p>There are a couple of possibilities based upon my experience:</p>

<ol>
<li><p>You may not have specified <code>region-id</code> in Ansible, which means it will default to the region of the Resource Group.  Thus you may have a Resource Group in a region that does in-fact not support <code>Standard_D4s_v3</code>.</p></li>
<li><p>From time to time specific instance types are unavailable in a region due to resource constraints from Azure, this is usually a temporary state, so trying again in a few hours will work.</p></li>
<li><p><a href="https://docs.microsoft.com/en-us/azure/azure-subscription-service-limits" rel="nofollow noreferrer">limits or quotas on your subscription</a> might be preventing you from creating the Virtual Machine, although I would expect that you would get a different, more descriptive error message if this were the case.</p></li>
</ol>

CC BY-SA 4.0
2019-11-04T14:39:03.090Z
I was going to provide an answer along the lines of using  `azure_rm_resourcegroup_info` module to gather facts about the resource group to filter on, but I wasn't sure if this was a valid approach. If it were, perhaps this approach could be added to the answer?
Bruce Becker
CC BY-SA 4.0
2019-11-04T14:42:26.163Z
@BruceBecker I think that's a perfectly valid answer in its own right, probably a better answer in the long run as it's impervious to whatever root cause is a problem.
Richard Slater
CC BY-SA 4.0
2019-11-04T14:15:49.827Z
2019-11-04T14:15:49.827Z
Richard Slater
<p>I am trying to create a VM with a playbook like this:</p>

<pre><code>  tasks:

  ...

  - name: Create VM
    azure_rm_virtualmachine:
      resource_group: AnsibleResourcEGroup
      name: AnsibleVM
      vm_size: Standard_D4s_v3

      ...

</code></pre>

<p>When I run the playbook, this "Create VM" task fails:</p>

<pre><code>fatal: [localhost]: FAILED! =&gt; {
  "changed": false, 
  "msg": "Error creating or updating virtual machine AnsibleVM - Azure Error: SkuNotAvailable\nMessage: The requested size for resource '/subscriptions/some-subscription-id/resourceGroups/some-resource-group-name/providers/Microsoft.Compute/virtualMachines/AnsibleVM' is currently not available in location 'region-name' zones '' for subscription 'some-subscription-id'. Please try another size or deploy to a different location or zones. See https://aka.ms/azureskunotavailable for details."
}
</code></pre>

<p>However, when I use <code>az</code> cli to enquery for the available vm size, the size <code>Standard_D4s_v3</code> seems available:</p>

<pre><code>$ az vm list-skus --location region-id --size Standard_D --output table

ResourceType     Locations    Name                Zones    Capabilities                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Restrictions
---------------  -----------  ------------------  -------  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  --------------

...

virtualMachines  region-id    Standard_D2s_v3     1,2,3    ['MaxResourceVolumeMB=16384', 'OSVhdSizeMB=1047552', 'vCPUs=2', 'HyperVGenerations=V1,V2', 'MemoryGB=8', 'MaxDataDiskCount=4', 'LowPriorityCapable=True', 'PremiumIO=True', 'vCPUsAvailable=2', 'ACUs=160', 'vCPUsPerCore=2', 'CombinedTempDiskAndCachedIOPS=4000', 'CombinedTempDiskAndCachedReadBytesPerSecond=33554432', 'CombinedTempDiskAndCachedWriteBytesPerSecond=33554432', 'CachedDiskBytes=53687091200', 'UncachedDiskIOPS=3200', 'UncachedDiskBytesPerSecond=50331648', 'EphemeralOSDiskSupported=True', 'AcceleratedNetworkingEnabled=False', 'RdmaEnabled=False', 'MaxNetworkInterfaces=2']                                           None
virtualMachines  region-id    Standard_D4s_v3     1,2,3    ['MaxResourceVolumeMB=32768', 'OSVhdSizeMB=1047552', 'vCPUs=4', 'HyperVGenerations=V1,V2', 'MemoryGB=16', 'MaxDataDiskCount=8', 'LowPriorityCapable=True', 'PremiumIO=True', 'vCPUsAvailable=4', 'ACUs=160', 'vCPUsPerCore=2', 'CombinedTempDiskAndCachedIOPS=8000', 'CombinedTempDiskAndCachedReadBytesPerSecond=67108864', 'CombinedTempDiskAndCachedWriteBytesPerSecond=67108864', 'CachedDiskBytes=107374182400', 'UncachedDiskIOPS=6400', 'UncachedDiskBytesPerSecond=100663296', 'EphemeralOSDiskSupported=True', 'AcceleratedNetworkingEnabled=True', 'RdmaEnabled=False', 'MaxNetworkInterfaces=2']                                         None
virtualMachines  region-id    Standard_D8s_v3     1,2,3    ['MaxResourceVolumeMB=65536', 'OSVhdSizeMB=1047552', 'vCPUs=8', 'HyperVGenerations=V1,V2', 'MemoryGB=32', 'MaxDataDiskCount=16', 'LowPriorityCapable=True', 'PremiumIO=True', 'vCPUsAvailable=8', 'ACUs=160', 'vCPUsPerCore=2', 'CombinedTempDiskAndCachedIOPS=16000', 'CombinedTempDiskAndCachedReadBytesPerSecond=134217728', 'CombinedTempDiskAndCachedWriteBytesPerSecond=134217728', 'CachedDiskBytes=214748364800', 'UncachedDiskIOPS=12800', 'UncachedDiskBytesPerSecond=201326592', 'EphemeralOSDiskSupported=True', 'AcceleratedNetworkingEnabled=True', 'RdmaEnabled=False', 'MaxNetworkInterfaces=4']                                    None

...

</code></pre>

<p>which does not seems right.</p>

<p>So which part of my understanding wrong? How should I make sure that a VM size is available in my region?</p>

<ansible><azure><vm>
How to make sure the specified Azure vm size available?
Koala Yeung
# How to make sure the specified Azure vm size available?

(Asked by: username_0 on 2019-11-04)

I am trying to create a VM with a playbook like this:
  tasks:

  ...

  - name: Create VM
    azure_rm_virtualmachine:
      resource_group: AnsibleResourcEGroup
      name: AnsibleVM
      vm_size: Standard_D4s_v3

      ...


When I run the playbook, this "Create VM" task fails:
fatal: [localhost]: FAILED! => {
  "changed": false, 
  "msg": "Error creating or updating virtual machine AnsibleVM - Azure Error: SkuNotAvailable\nMessage: The requested size for resource '/subscriptions/some-subscription-id/resourceGroups/some-resource-group-name/providers/Microsoft.Compute/virtualMachines/AnsibleVM' is currently not available in location 'region-name' zones '' for subscription 'some-subscription-id'. Please try another size or deploy to a different location or zones. See https://aka.ms/azureskunotavailable for details."
}

However, when I use az cli to enquery for the available vm size, the size Standard_D4s_v3 seems available:
$ az vm list-skus --location region-id --size Standard_D --output table

ResourceType     Locations    Name                Zones    Capabilities                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Restrictions
---------------  -----------  ------------------  -------  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  --------------

...

virtualMachines  region-id    Standard_D2s_v3     1,2,3    ['MaxResourceVolumeMB=16384', 'OSVhdSizeMB=1047552', 'vCPUs=2', 'HyperVGenerations=V1,V2', 'MemoryGB=8', 'MaxDataDiskCount=4', 'LowPriorityCapable=True', 'PremiumIO=True', 'vCPUsAvailable=2', 'ACUs=160', 'vCPUsPerCore=2', 'CombinedTempDiskAndCachedIOPS=4000', 'CombinedTempDiskAndCachedReadBytesPerSecond=33554432', 'CombinedTempDiskAndCachedWriteBytesPerSecond=33554432', 'CachedDiskBytes=53687091200', 'UncachedDiskIOPS=3200', 'UncachedDiskBytesPerSecond=50331648', 'EphemeralOSDiskSupported=True', 'AcceleratedNetworkingEnabled=False', 'RdmaEnabled=False', 'MaxNetworkInterfaces=2']                                           None
virtualMachines  region-id    Standard_D4s_v3     1,2,3    ['MaxResourceVolumeMB=32768', 'OSVhdSizeMB=1047552', 'vCPUs=4', 'HyperVGenerations=V1,V2', 'MemoryGB=16', 'MaxDataDiskCount=8', 'LowPriorityCapable=True', 'PremiumIO=True', 'vCPUsAvailable=4', 'ACUs=160', 'vCPUsPerCore=2', 'CombinedTempDiskAndCachedIOPS=8000', 'CombinedTempDiskAndCachedReadBytesPerSecond=67108864', 'CombinedTempDiskAndCachedWriteBytesPerSecond=67108864', 'CachedDiskBytes=107374182400', 'UncachedDiskIOPS=6400', 'UncachedDiskBytesPerSecond=100663296', 'EphemeralOSDiskSupported=True', 'AcceleratedNetworkingEnabled=True', 'RdmaEnabled=False', 'MaxNetworkInterfaces=2']                                         None
virtualMachines  region-id    Standard_D8s_v3     1,2,3    ['MaxResourceVolumeMB=65536', 'OSVhdSizeMB=1047552', 'vCPUs=8', 'HyperVGenerations=V1,V2', 'MemoryGB=32', 'MaxDataDiskCount=16', 'LowPriorityCapable=True', 'PremiumIO=True', 'vCPUsAvailable=8', 'ACUs=160', 'vCPUsPerCore=2', 'CombinedTempDiskAndCachedIOPS=16000', 'CombinedTempDiskAndCachedReadBytesPerSecond=134217728', 'CombinedTempDiskAndCachedWriteBytesPerSecond=134217728', 'CachedDiskBytes=214748364800', 'UncachedDiskIOPS=12800', 'UncachedDiskBytesPerSecond=201326592', 'EphemeralOSDiskSupported=True', 'AcceleratedNetworkingEnabled=True', 'RdmaEnabled=False', 'MaxNetworkInterfaces=4']                                    None

...


which does not seems right.
So which part of my understanding wrong? How should I make sure that a VM size is available in my region?

**Tags:** ansible, azure, vm


---

## 1 answers

### Answer by username_1 on 2019-11-04. Score: 2 | Accepted answer

There are a couple of possibilities based upon my experience:

1. You may not have specified `region-id` in Ansible, which means it will default to the region of the Resource Group. Thus you may have a Resource Group in a region that does in-fact not support `Standard_D4s_v3`.
2. From time to time specific instance types are unavailable in a region due to resource constraints from Azure, this is usually a temporary state, so trying again in a few hours will work.
3. [limits or quotas on your subscription](https://docs.microsoft.com/en-us/azure/azure-subscription-service-limits) might be preventing you from creating the Virtual Machine, although I would expect that you would get a different, more descriptive error message if this were the case.

> **Comments:**
> **username_2**: I was going to provide an answer along the lines of using  `azure_rm_resourcegroup_info` module to gather facts about the resource group to filter on, but I wasn't sure if this was a valid approach. If it were, perhaps this approach could be added to the answer?  
> **username_1**: @BruceBecker I think that's a perfectly valid answer in its own right, probably a better answer in the long run as it's impervious to whatever root cause is a problem.  

---

