New-AzVM command is not working for Windows 2022 Image alias
Description
Hello Team,
I am trying to create a VM setup using power-shell script. I tried to use Win2022Datacenter in New-AZVM command. command is failed with VM image is not found error. I found this image alias from this public documentation: https://learn.microsoft.com/en-us/azure/virtual-machines/windows/cli-ps-findimage
Thanks & Regards, Sriram Kedarasetti.
Issue script & Debug output
Creating VNet, Subnet, NIC, VM, Public ip, dataplane nsg and attaching dataplane nsg to NIC...
DEBUG: 1:50:05 AM - NewAzureVMCommand begin processing with ParameterSet 'SimpleParameterSet'.
DEBUG: 1:50:05 AM - using account id '[email protected]'...
DEBUG: [Common.Authentication]: Authenticating using Account: '[email protected]', environment: 'AzureCloud', tenant: '33e01921-4d64-4f8c-a055-5bdaffd5e33d'
DEBUG: 1:50:05 AM - [SilentAuthenticator] Calling SharedTokenCacheCredential.GetTokenAsync - TenantId:'33e01921-4d64-4f8c-a055-5bdaffd5e33d', Scopes:'https://management.core.windows.net//.default', AuthorityHost:'https://login.microsoftonline.com/', UserId:'[email protected]'
DEBUG: SharedTokenCacheCredential.GetToken invoked. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId:
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05 - ] Azure region was not configured or could not be discovered. Not using a regional authority.
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05] Found 1 cache accounts and 0 broker accounts
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05] Returning 1 accounts
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05 - ] MSAL MSAL.Desktop with assembly version '4.30.1.0'. CorrelationId(f17a5439-e64b-4bef-a681-612c01cfa4bb)
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05 - ] === AcquireTokenSilent Parameters ===
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05 - ] LoginHint provided: False
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05 - ] Account provided: True
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05 - ] ForceRefresh: False
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05 - ]
=== Request Data ===
Authority Provided? - True
Scopes - https://management.core.windows.net//.default
Extra Query Params Keys (space separated) -
ApiId - AcquireTokenSilent
IsConfidentialClient - False
SendX5C - False
LoginHint ? False
IsBrokerConfigured - False
HomeAccountId - False
CorrelationId - f17a5439-e64b-4bef-a681-612c01cfa4bb
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05 - ] === Token Acquisition (SilentRequest) started:
Authority Host: login.microsoftonline.com
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05 - ] Azure region was not configured or could not be discovered. Not using a regional authority.
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05 - ] Access token is not expired. Returning the found cache entry. [Current time (01/25/2024 09:50:05) - Expiration Time (01/25/2024 11:06:08 +00:00) - Extended Expiration Time (01/25/2024 11:06:08 +00:00)]
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05 - ] Returning access token found in cache. RefreshOn exists ? False
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05 - ] Fetched access token from host login.microsoftonline.com.
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05 - ] === Token Acquisition finished successfully. An access token was returned with Expiration Time: 01/25/2024 11:06:08 +00:00 and Scopes https://management.core.windows.net//user_impersonation https://management.core.windows.net//.default
DEBUG: SharedTokenCacheCredential.GetToken succeeded. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId: ExpiresOn: 2024-01-25T11:06:08.0000000+00:00
DEBUG: [Common.Authentication]: Received token with LoginType 'User', Tenant: '33e01921-4d64-4f8c-a055-5bdaffd5e33d', UserId: '[email protected]'
DEBUG: [Common.Authentication]: Authenticating using Account: '[email protected]', environment: 'AzureCloud', tenant: '33e01921-4d64-4f8c-a055-5bdaffd5e33d'
DEBUG: 1:50:05 AM - [SilentAuthenticator] Calling SharedTokenCacheCredential.GetTokenAsync - TenantId:'33e01921-4d64-4f8c-a055-5bdaffd5e33d', Scopes:'https://management.core.windows.net//.default', AuthorityHost:'https://login.microsoftonline.com/', UserId:'[email protected]'
DEBUG: SharedTokenCacheCredential.GetToken invoked. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId:
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05 - ] Azure region was not configured or could not be discovered. Not using a regional authority.
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05] Found 1 cache accounts and 0 broker accounts
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05] Returning 1 accounts
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05 - ] MSAL MSAL.Desktop with assembly version '4.30.1.0'. CorrelationId(6cf48258-4c07-487b-b8af-6d962f663a6b)
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05 - ] === AcquireTokenSilent Parameters ===
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05 - ] LoginHint provided: False
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05 - ] Account provided: True
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05 - ] ForceRefresh: False
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05 - ]
=== Request Data ===
Authority Provided? - True
Scopes - https://management.core.windows.net//.default
Extra Query Params Keys (space separated) -
ApiId - AcquireTokenSilent
IsConfidentialClient - False
SendX5C - False
LoginHint ? False
IsBrokerConfigured - False
HomeAccountId - False
CorrelationId - 6cf48258-4c07-487b-b8af-6d962f663a6b
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05 - ] === Token Acquisition (SilentRequest) started:
Authority Host: login.microsoftonline.com
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05 - ] Azure region was not configured or could not be discovered. Not using a regional authority.
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05 - ] Access token is not expired. Returning the found cache entry. [Current time (01/25/2024 09:50:05) - Expiration Time (01/25/2024 11:06:08 +00:00) - Extended Expiration Time (01/25/2024 11:06:08 +00:00)]
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05 - ] Returning access token found in cache. RefreshOn exists ? False
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05 - ] Fetched access token from host login.microsoftonline.com.
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:05 - ] === Token Acquisition finished successfully. An access token was returned with Expiration Time: 01/25/2024 11:06:08 +00:00 and Scopes https://management.core.windows.net//user_impersonation https://management.core.windows.net//.default
DEBUG: SharedTokenCacheCredential.GetToken succeeded. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId: ExpiresOn: 2024-01-25T11:06:08.0000000+00:00
DEBUG: [Common.Authentication]: Received token with LoginType 'User', Tenant: '33e01921-4d64-4f8c-a055-5bdaffd5e33d', UserId: '[email protected]'
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
GET
Absolute Uri:
https://management.azure.com/subscriptions/558f48f5-8789-4a28-b05b-956596d499af/resourceGroups/RunnersORgTestWcus/providers/Microsoft.Compute/images/Win2022Datacenter?api-version=2021-07-01
Headers:
x-ms-client-request-id : b5def1b9-0546-407f-855c-b75d20235fbc
accept-language : en-US
Body:
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
NotFound
Headers:
Pragma : no-cache
x-ms-failure-cause : gateway
x-ms-request-id : 14ab65a6-f511-46bd-861b-652da3f04654
x-ms-correlation-request-id : 14ab65a6-f511-46bd-861b-652da3f04654
x-ms-routing-request-id : SOUTHEASTASIA:20240125T095006Z:14ab65a6-f511-46bd-861b-652da3f04654
Strict-Transport-Security : max-age=31536000; includeSubDomains
X-Content-Type-Options : nosniff
Cache-Control : no-cache
Date : Thu, 25 Jan 2024 09:50:06 GMT
Body:
{
"error": {
"code": "ResourceNotFound",
"message": "The Resource 'Microsoft.Compute/images/Win2022Datacenter' under resource group 'RunnersORgTestWcus' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix"
}
}
New-AzVM : Can't find the image 'Win2022Datacenter'.
At C:\RunnerDeploymentAutomation\Overlake\OverlakeNSG\OverlakeNSG-RunnerDeployment.ps1:112 char:11
+ $vm = New-AzVM `
+ ~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzVM], ArgumentException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.NewAzureVMCommand
New-AzVM : Can't find the image 'Win2022Datacenter'.
At C:\RunnerDeploymentAutomation\Overlake\OverlakeNSG\OverlakeNSG-RunnerDeployment.ps1:112 char:11
+ $vm = New-AzVM `
+ ~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzVM], ArgumentException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.NewAzureVMCommand
DEBUG: AzureQoSEvent: Module: Az.Compute:4.22.0; CommandName: New-AzVM; PSVersion: 3.0.0.0; IsSuccess: False; Duration: 00:00:01.1274084; Exception: Can't find the image 'Win2022Datacenter'.;
DEBUG: Finish sending metric.
DEBUG: 1:50:07 AM - NewAzureVMCommand end processing.
Retrieving public Ip details...
DEBUG: 1:50:07 AM - GetAzurePublicIpAddressCommand begin processing with ParameterSet 'NoExpandStandAloneIp'.
DEBUG: 1:50:07 AM - using account id '[email protected]'...
DEBUG: [Common.Authentication]: Authenticating using Account: '[email protected]', environment: 'AzureCloud', tenant: '33e01921-4d64-4f8c-a055-5bdaffd5e33d'
DEBUG: 1:50:07 AM - [SilentAuthenticator] Calling SharedTokenCacheCredential.GetTokenAsync - TenantId:'33e01921-4d64-4f8c-a055-5bdaffd5e33d', Scopes:'https://management.core.windows.net//.default', AuthorityHost:'https://login.microsoftonline.com/', UserId:'[email protected]'
DEBUG: SharedTokenCacheCredential.GetToken invoked. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId:
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:07 - ] Azure region was not configured or could not be discovered. Not using a regional authority.
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:07] Found 1 cache accounts and 0 broker accounts
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:07] Returning 1 accounts
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:07 - ] MSAL MSAL.Desktop with assembly version '4.30.1.0'. CorrelationId(9ecc2331-89cd-4316-8b15-d62fe30ab4bc)
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:07 - ] === AcquireTokenSilent Parameters ===
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:07 - ] LoginHint provided: False
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:07 - ] Account provided: True
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:07 - ] ForceRefresh: False
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:07 - ]
=== Request Data ===
Authority Provided? - True
Scopes - https://management.core.windows.net//.default
Extra Query Params Keys (space separated) -
ApiId - AcquireTokenSilent
IsConfidentialClient - False
SendX5C - False
LoginHint ? False
IsBrokerConfigured - False
HomeAccountId - False
CorrelationId - 9ecc2331-89cd-4316-8b15-d62fe30ab4bc
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:07 - ] === Token Acquisition (SilentRequest) started:
Authority Host: login.microsoftonline.com
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:07 - ] Azure region was not configured or could not be discovered. Not using a regional authority.
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:07 - ] Access token is not expired. Returning the found cache entry. [Current time (01/25/2024 09:50:07) - Expiration Time (01/25/2024 11:06:08 +00:00) - Extended Expiration Time (01/25/2024 11:06:08 +00:00)]
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:07 - ] Returning access token found in cache. RefreshOn exists ? False
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:07 - ] Fetched access token from host login.microsoftonline.com.
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [01/25/2024 09:50:07 - ] === Token Acquisition finished successfully. An access token was returned with Expiration Time: 01/25/2024 11:06:08 +00:00 and Scopes https://management.core.windows.net//user_impersonation https://management.core.windows.net//.default
DEBUG: SharedTokenCacheCredential.GetToken succeeded. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId: ExpiresOn: 2024-01-25T11:06:08.0000000+00:00
DEBUG: [Common.Authentication]: Received token with LoginType 'User', Tenant: '33e01921-4d64-4f8c-a055-5bdaffd5e33d', UserId: '[email protected]'
DEBUG: ============================ HTTP REQUEST ============================
Environment data
PS C:\RunnerDeploymentAutomation\Overlake\OverlakeNSG> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.22621.2506
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22621.2506
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Module versions
PS C:\RunnerDeploymentAutomation\Overlake\OverlakeNSG> Get-Module Az*
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 2.7.3 Az.Accounts {Add-AzEnvironment, Clear-AzContext, Clear-AzDefault, Connect-AzAccount...}
Script 4.22.0 Az.Compute {Add-AzImageDataDisk, Add-AzVhd, Add-AzVMAdditionalUnattendContent, Add-AzVMDataDisk...}
Script 4.14.0 Az.Network {Add-AzApplicationGatewayAuthenticationCertificate, Add-AzApplicationGatewayBackendAddressPool, Add...
Script 5.2.0 Az.Resources {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAssignment, Get-AzDeployment...}
Script 4.2.0 Az.Storage {Add-AzRmStorageContainerLegalHold, Add-AzStorageAccountManagementPolicyAction, Add-AzStorageAccoun...
Error output
No response
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Drewm3, @TravisCragg-MSFT, @nikhilpatel909, @sandeepraichura, @hilaryw29, @GabstaMSFT.
@Sriram-Kedarasetti can you share the script you are using to create the VM? It is likely that the image reference is not correct. Also, I would recommend updating your Azure PowerShell cmdlets.
Please find the attachment for the script I used to create the VM. I tried the script by updating the ps cmdlets. Still faced the same issue. OverlakeNSG-RunnerDeployment.zip
This was a bug in the docs, the new alias to use is Win2022AzureEdition. The docs are being updated.
The docs should be updated in a couple of days.
[like] S M S R Phani Sai Kedarasetti ... reacted to your message:
From: Adam Sandor @.> Sent: Monday, July 22, 2024 3:07:39 PM To: Azure/azure-powershell @.> Cc: S M S R Phani Sai Kedarasetti (HCL Technologies Corporate Services) @.>; Mention @.> Subject: Re: [Azure/azure-powershell] New-AzVM command is not working for Windows 2022 Image alias (Issue #24039)
The docs should be updated in a couple of days.
— Reply to this email directly, view it on GitHubhttps://github.com/Azure/azure-powershell/issues/24039#issuecomment-2243192914, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A3RUB7XPFK3FFTECHSTTEVTZNUN3XAVCNFSM6AAAAABCKHHGCKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENBTGE4TEOJRGQ. You are receiving this because you were mentioned.Message ID: @.***>