How do I fix the "'VMCustomization' is not enabled for the Subscription" when creating a VM using PowerShell 7.2?

Anders Lindberg 1 Reputation point
2022-03-03T14:03:03.683+00:00

Hi all.

I'm trying to learn how to work with Azure through PowerShell (specifically PowerShell 7.2) to manage resources and eventually automate it (I think). It's part of this resource for learning PowerShell, which can be found here: https://learn.microsoft.com/en-us/learn/paths/powershell/

I'm in the final module, where you use PowerShell to manage Azure resources. Think it mentioned that you will automate things as well, but I haven't gotten that far. The first step is to create a VM using New-AzVM and it doesn't work because I get this message:
179660-image.png

I got this when doing this step:

New-AzVm -ResourceGroupName learn-10a7edbb-0445-470c-991d-cf39a63aef5b -Name "testvm-eus-01" -Credential (Get-Credential) -Location "East US" -Image UbuntuLTS -OpenPorts 22 -PublicIpAddressName "testvm-01"  

I also tried using a private Azure subscription that I just created (and thus I'm not sure if there was any setup step I missed), and entered something like this:

New-AzVm -ResourceGroupName <resource-group-name> -Name <name> -Credential (Get-Credential) -Location <location> -Image UbuntuLTS -OpenPorts <relevant-port-number> -PublicIpAddressName <another-name>  

I get the same error again. To my understanding this is the first step, so I don't think I have missed any preceding step, but could of course be wrong (though on my private subscription I did of connect to azure and create a resource group that I was going to use, all through PowerShell and it worked fine). Does anyone have any idea? New to this so I'm not sure where to begin to figure out the problem except asking.

Also my googling has found a similar issue in another place, namely for the Azure CLI version 2.33, but I made sure to update mine and it's on version 2.34.1.

Thanks for any help.

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,164 questions
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,125 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. kobulloc-MSFT 23,496 Reputation points Microsoft Employee
    2022-03-04T19:39:14.11+00:00

    @Anders Lindberg (and adding @DustinShockley and @Joe Martin ),

    Issue:
    Using the New-AzVM command results in the following VMCustomization error:
    New-AzVM: 'VMCustomization' is not enabled for the Subscription. Please register the Subscription for 'Microsoft.Compute/VMCustomizationPreview' to use the feature.

    Update: We are releasing a fix in Az.Compute version 4.24.1.

    Solution:
    Update the Az.Compute module to the current version on your local client (Azure Cloud Shell should be updated shortly):

    Update-Module Az.Compute  
    

    If you are using the Azure Cloud Shell, use the following command and restart the Cloud Shell (by pressing the power button next to the "?"):

    Install-Module Az.Compute -Force  
    

    185462-image.png

    Old/Alternate Workaround:
    On your local PowerShell client you can install and revert back to Az.Compute version 4.23.0, which is unaffected by this issue:

    1. Check your current Az.Compute version number using either Get-Module Az.Compute (this will return nothing if the module hasn't been loaded) or Get-Module -ListAvailable -Name Az.Compute -Refresh
    2. Install Az.Compute version 4.23: Install-Module Az.Compute -RequiredVersion 4.23.0 -Force
    3. Switch to Az.Compute version 4.23: Import-Module Az.Compute -RequiredVersion 4.23.0
    4. You should now be able to use New-AzVm

    180494-image.png

    Details:
    Using the New-AzVM command results in the following VMCustomization error:

    New-AzVM: 'VMCustomization' is not enabled for the Subscription. Please register the Subscription for 'Microsoft.Compute/VMCustomizationPreview' to use the feature.

    180257-image.png

    It appears we're seeing the same issue now in Azure PowerShell that we saw in Azure CLI (Azure CLI is separate from Azure PowerShell but can also be run within PowerShell which causes some confusion--this documentation helps to clarify both the differences and similarities).

    Cause:
    This is unintended behavior with New-AzVM. I will continue to update this thread as we learn more.

    1. This impacts Az.Compute version 4.24.0 (see workaround above)
    2. We are releasing a fix for version 4.24.1
    3. It appears this is related to the 7.2.0 release in February, 2022
    4. Both desktop and Azure Cloud Shell clients are affected
    5. Azure CLI (az vm create) is not affected outside of the known issue for 2.33.0

    Out of Curiosity, What is VM Customization (Private Preview)?
    For those who are curious, VM Customization is in private preview and is designed to provide customization for Hyperthreading and Constrained Cores:

    https://aka.ms/vmcustomization

    The VM Customization feature is designed to provide two important customization features to customers, Hyperthreading and Constrained Cores. Hyperthreading provides customers the ability to disable hyperthreading on their VMs at the time of creation and Constrained Cores allows customization of the “constrained core counts” which helps to optimize the database licensing cost customers pay for.

    2 people found this answer helpful.

  2. Timothy Gonzalez 6 Reputation points
    2022-04-04T03:20:08.053+00:00

    @Andrew Molina In order to complete the learning exercises with the sandbox you can do the following:

    1. Install or update powershell 7 to the latest version
    2. Install the AZ module
    3. Run Connect-AzAccount
    4. In the learning exercise click "Activate Sandbox"
    5. Run Get-AzSubscription and copy the ID guid
    6. Run Set-AzContext -Subscription 'ID_GUID_HERE'
    7. You can now complete the learning exercise in the sandbox using powershell locally

    189592-image.png

    1 person found this answer helpful.

  3. Anders Lindberg 1 Reputation point
    2022-03-03T14:32:36.35+00:00

    So I kind of managed to find a solution eventually that seems to work: Use Azure CLI (but not version 2.33.0).

    Since this was a bug in the Azure CLI earlier, maybe whatever bug caused Azure CLI to do this a while ago is still affecting (or has started to affect) the PowerShell module for working with Azure.

    Anyone with more experience then me who can come with more insight is very welcome to do so!


  4. Andrew Molina 1 Reputation point
    2022-03-31T00:44:43.95+00:00

    How do you work around this if you are using the sandbox in learning modules? Are we just out of luck? Would be nice to see spinning up a VM in the learning module so I don't have to run this command on my local machine PowerShell and then have to pay for it.

    188505-learning-module-powershell-broke.png