question

AndersLindberg-2131 avatar image
0 Votes"
AndersLindberg-2131 asked DenmarkDave-1620 commented

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

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://docs.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-machinesazure-automation
image.png (7.8 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AndersLindberg-2131 avatar image
0 Votes"
AndersLindberg-2131 answered kobulloc-MSFT commented

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!

· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello, @AndersLindberg-2131!

Just to confirm, once you upgraded Azure CLI from version 2.33.0 the issue was resolved or were you still seeing this with another Azure CLI version?

0 Votes 0 ·

I didn't use the Azure CLI initially (I used the Az PowerShell module) and it was never at 2.33.0. Mentioned it because I figured that since I knew it had the issue in the passed it might be relevant in solving this. Was not using it since I just focused on using PowerShell because that was what the learning resource was teaching me. I didn't think about using Azure CLI for an embarrassingly long time. When I did use it, it worked without a problem. The issue seems to have been with the Az PowerShell module and not the Azure CLI.

0 Votes 0 ·
kobulloc-MSFT avatar image kobulloc-MSFT AndersLindberg-2131 ·

Ah, thank you for the clarification! Let me do some additional investigation on New-AzVm with PowerShell 7.2.

0 Votes 0 ·
Show more comments
kobulloc-MSFT avatar image
2 Votes"
kobulloc-MSFT answered kobulloc-MSFT commented

@AndersLindberg-2131 (and adding @DustinShockley-2745 and @JoeMartin-0389),

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.



image.png (209.2 KiB)
image.png (190.2 KiB)
image.png (562.2 KiB)
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

thank you for the explanation and workaround.

crazy that this passed testing and was released. It is still broken at time of writing. Renders cloud shell useless for creating VMs.

0 Votes 0 ·
kobulloc-MSFT avatar image kobulloc-MSFT HribernikAndrej-3923 ·

@HribernikAndrej-3923,

Thank you for your patience! We realize that this is a high impacting issue and we are running through tests on a fix which we hope to release shortly. If you want to use the Azure Cloud Shell to create VMs, you can still use the Azure CLI.

2 Votes 2 ·

Thank you very much for explanation and workaround :)

0 Votes 0 ·
kobulloc-MSFT avatar image kobulloc-MSFT SzvitkZsoltGyrgy-7828 ·

No worries, @ SiDoCiOuSSiD-4633. Happy to help!

1 Vote 1 ·
AndrewMolina-0921 avatar image
0 Votes"
AndrewMolina-0921 answered DenmarkDave-1620 commented

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



· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@AndrewMolina-0921, thank you for bringing this to our attention and for providing a screenshot. My understanding was that all Cloud Shell errors had been resolved but we'll need to investigate this further.

0 Votes 0 ·

I am also running into this exact issue using cloudshell. I tried install-module az.compute -force and it still is running 4.24.0.

This is related to a lab exercise on MS Learn. Here's a link.


0 Votes 0 ·
TimothyGonzalez-2041 avatar image
1 Vote"
TimothyGonzalez-2041 answered DenmarkDave-1620 commented

@AndrewMolina-0921 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



image.png (117.4 KiB)
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

where do you suggest to complete the first 3 steps you mentioned here?
Install or update powershell 7 to the latest version

Install the AZ module

Run Connect-AzAccount

in learning excercise we cant do that right?

0 Votes 0 ·

@Aboyinthebox installing and using powershell is covered in the module Automate Azure tasks using scripts with PowerShell . You will need to install powershell locally, activate the sandbox in the learning exercise, but you can't use the cloudshell in the learning exercise. You can still however point to the same azure environment that the cloudshell in the learning exercises uses with powershell locally. The cloudshell is really just a nice to have. What's most important is the azure sandbox where you can experiment freely. Is there anything preventing you from installing powershell locally?

0 Votes 0 ·

Thank you!

0 Votes 0 ·