Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.21k stars 3.81k forks source link

Get-AzVMRunCommand Does not show VM run Commands. But When I check from the Azure Console for the VM I can see the Default Run Commands. #25978

Open nuwanpofficial opened 2 weeks ago

nuwanpofficial commented 2 weeks ago

Description

Comamnd Get-AzVMRunCommand -ResourceGroupName server-rg -VMName sever1 -RunCommandName RunPowerShellScript

RunPowerShellScript is a default Run Command given in Azure VMs. But When I execute the above Command it give resource not found error.

I am executing this in Azure CloudShell itself just to see. But when I run this in my laptop or in a Azure VM its the same.

But Invoke-AzVMRunCommand for the same Resource Group and VM works without any issues.

Kindly assist on this. Thank you.

Script or Debug output

Get-AzVMRunCommand -ResourceGroupName server-rg -VMName sever1 -RunCommandName RunPowerShellScript

Environment data

No response

Module versions

No response

Error output

Get-AzVMRunCommand: The Resource 'Microsoft.Compute/virtualMachines/server1/runCommands/RunPowerShellScript' under resource group 'server-rg' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
ErrorCode: ResourceNotFound
ErrorMessage: The Resource 'Microsoft.Compute/virtualMachines/server1/runCommands/RunPowerShellScript' under resource group 'server-rg' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
ErrorTarget: 
StatusCode: 404
ReasonPhrase: Not Found
OperationID : 44041bf5-8f5b-4937-9c06-eef7ca7de885
isra-fel commented 1 week ago

Can you enable debug log and share it here? Do redact sensitive information. Debug log contains details of the HTTP request that is helpful to diagnose the root cause. Here's how to: https://learn.microsoft.com/en-us/powershell/azure/troubleshooting?view=azps-12.2.0#enable-debug-logging

nuwanpofficial commented 1 week ago

Below is the Debug Log for the Command

PS /home/nuwan> Get-AzVMRunCommand -ResourceGroupName svr-mgmt-learn-rg -VMName svr-mgmt-wsus-z1 -RunCommandName RunPowerShellScript -Debug

DEBUG: 3:58:09 AM - [ConfigManager] Got [True] from [DisplaySecretsWarning], Module = [], Cmdlet = []. DEBUG: 3:58:09 AM - GetAzureVmRunCommand begin processing with ParameterSet '__AllParameterSets'. DEBUG: 3:58:09 AM - using account id 'MSI@XXXXX'... DEBUG: 3:58:09 AM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True]. DEBUG: [Common.Authentication]: Authenticating using Account: 'MSI@XXXXX', environment: 'AzureCloud', tenant: 'xxxx-yyyy-zzzz' DEBUG: 3:58:09 AM - [ConfigManager] Got nothing from [DisableInstanceDiscovery], Module = [], Cmdlet = []. Returning default value [False]. DEBUG: 3:58:09 AM - [ManagedServiceIdentityAuthenticator] Calling ManagedIdentityCredential.GetTokenAsync - TenantId:'xxxx-yyyy-zzzz', Scopes:'https://management.core.windows.net/', UserId:'' DEBUG: ManagedIdentityCredential.GetToken invoked. Scopes: [ https://management.core.windows.net/ ] ParentRequestId: DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-09-04 03:58:09Z - e7793300-6e2c-423d-b506-c414e5775373] MSAL MSAL.CoreCLR with assembly version '4.61.3.0'. CorrelationId(e7793300-6e2c-423d-b506-c414e5775373) DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-09-04 03:58:09Z - e7793300-6e2c-423d-b506-c414e5775373] === AcquireTokenForClientParameters === SendX5C: False ForceRefresh: False

DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-09-04 03:58:09Z - e7793300-6e2c-423d-b506-c414e5775373] === Request Data === Authority Provided? - True Scopes - https://management.core.windows.net/ Extra Query Params Keys (space separated) - ApiId - AcquireTokenForClient IsConfidentialClient - True SendX5C - False LoginHint ? False IsBrokerConfigured - False HomeAccountId - False CorrelationId - e7793300-6e2c-423d-b506-c414e5775373 UserAssertion set: False LongRunningOboCacheKey set: False Region configured:

DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-09-04 03:58:09Z - e7793300-6e2c-423d-b506-c414e5775373] === Token Acquisition (ClientCredentialRequest) started: Scopes: https://management.core.windows.net/ Authority Host: login.microsoftonline.com DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-09-04 03:58:09Z - e7793300-6e2c-423d-b506-c414e5775373] [Region discovery] Not using a regional authority. DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-09-04 03:58:09Z - e7793300-6e2c-423d-b506-c414e5775373] [Instance Discovery] Skipping Instance discovery because it is disabled. DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-09-04 03:58:09Z - e7793300-6e2c-423d-b506-c414e5775373] [ClientCredentialRequest] Acquiring a token from the token provider. DEBUG: Request [3e8799eb-70d5-4c28-b45b-cafb68d1b1e7] POST http://localhost:XXXXX/oauth2/token Content-Type:application/x-www-form-urlencoded Metadata:REDACTED x-ms-client-request-id:3e8799eb-70d5-4c28-b45b-cafb68d1b1e7 x-ms-return-client-request-id:true User-Agent:azsdk-net-Identity/1.12.0 (.NET 8.0.8; CBL-Mariner/Linux) client assembly: Azure.Identity DEBUG: Response [3e8799eb-70d5-4c28-b45b-cafb68d1b1e7] 200 OK (00.0s) X-Powered-By:REDACTED ETag:W/"8d8-GWkETdnEXHH0hSLaigZj2IOuHGQ" Date:Wed, 04 Sep 2024 03:58:09 GMT Connection:keep-alive Keep-Alive:REDACTED Content-Type:application/json; charset=utf-8 Content-Length:2264

DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-09-04 03:58:09Z - e7793300-6e2c-423d-b506-c414e5775373] Checking client info returned from the server.. DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-09-04 03:58:09Z - e7793300-6e2c-423d-b506-c414e5775373] Saving token response to cache.. DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-09-04 03:58:09Z - e7793300-6e2c-423d-b506-c414e5775373] [SaveTokenResponseAsync] ID Token not present in response. DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-09-04 03:58:09Z - e7793300-6e2c-423d-b506-c414e5775373] Cannot determine home account ID - or id token or no client info and no subject DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-09-04 03:58:09Z - e7793300-6e2c-423d-b506-c414e5775373] [SaveTokenResponseAsync] Saving AT in cache and removing overlapping ATs... DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-09-04 03:58:09Z - e7793300-6e2c-423d-b506-c414e5775373] Looking for scopes for the authority in the cache which intersect with https://management.core.windows.net/ DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-09-04 03:58:09Z - e7793300-6e2c-423d-b506-c414e5775373] Intersecting scope entries count - 0 DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-09-04 03:58:09Z - e7793300-6e2c-423d-b506-c414e5775373] === Token Acquisition finished successfully: DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-09-04 03:58:09Z - e7793300-6e2c-423d-b506-c414e5775373] AT expiration time: 9/4/2024 5:15:54 AM +00:00, scopes: https://management.core.windows.net/. source: IdentityProvider DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-09-04 03:58:09Z - e7793300-6e2c-423d-b506-c414e5775373] Fetched access token from host login.microsoftonline.com. DEBUG: ManagedIdentityCredential.GetToken succeeded. Scopes: [ https://management.core.windows.net/ ] ParentRequestId: ExpiresOn: 2024-09-04T05:15:54.3947601+00:00 DEBUG: [Common.Authentication]: Received token with LoginType 'User', Tenant: 'xxxx-yyyy-zzzz', UserId: 'MSI@XXXXX' DEBUG: ============================ HTTP REQUEST ============================

HTTP Method: GET

Absolute Uri: https://management.azure.com/subscriptions/xxxx-yyyy-zzzz-ssss/resourceGroups/svr-mgmt-learn-rg/providers/Microsoft.Compute/virtualMachines/svr-mgmt-wsus-z1/runCommands/RunPowerShellScript?api-version=2024-03-01

Headers: Accept-Language : en-US x-ms-client-request-id : 4a0b5ba0-6fc0-494f-9729-6eed19c47aeb

Body:

DEBUG: ============================ HTTP RESPONSE ============================

Status Code: NotFound

Headers: Cache-Control : no-cache Pragma : no-cache x-ms-failure-cause : gateway x-ms-request-id : 5de9f190-6186-4d7e-9081-2ecd093ef551 x-ms-correlation-request-id : 5de9f190-6186-4d7e-9081-2ecd093ef551 x-ms-routing-request-id : SOUTHEASTASIA:20240904T035809Z:5de9f190-6186-4d7e-9081-2ecd093ef551 Strict-Transport-Security : max-age=31536000; includeSubDomains X-Content-Type-Options : nosniff X-Cache : CONFIG_NOCACHE X-MSEdge-Ref : Ref A: 560C9D96D3464D4CA91C3145F2262952 Ref B: MAA201060516017 Ref C: 2024-09-04T03:58:09Z Date : Wed, 04 Sep 2024 03:58:09 GMT

Body: { "error": { "code": "ResourceNotFound", "message": "The Resource 'Microsoft.Compute/virtualMachines/svr-mgmt-wsus-z1/runCommands/RunPowerShellScript' under resource group 'svr-mgmt-learn-rg' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix" } }

DEBUG: 3:58:09 AM - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True]. DEBUG: 3:58:09 AM - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [True]. DEBUG: AzureQoSEvent: Module: Az.Compute:8.2.0; CommandName: Get-AzVMRunCommand; PSVersion: 7.4.5; IsSuccess: True; Duration: 00:00:00.3726287; SanitizeDuration: 00:00:00 DEBUG: 3:58:09 AM - [ConfigManager] Got [True] from [EnableDataCollection], Module = [], Cmdlet = []. DEBUG: 3:58:09 AM - GetAzureVmRunCommand end processing. DEBUG: 3:58:09 AM - [ConfigManager] Got nothing from [EnableErrorRecordsPersistence], Module = [], Cmdlet = []. Returning default value [False]. Get-AzVMRunCommand: The Resource 'Microsoft.Compute/virtualMachines/svr-mgmt-wsus-z1/runCommands/RunPowerShellScript' under resource group 'svr-mgmt-learn-rg' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix ErrorCode: ResourceNotFound ErrorMessage: The Resource 'Microsoft.Compute/virtualMachines/svr-mgmt-wsus-z1/runCommands/RunPowerShellScript' under resource group 'svr-mgmt-learn-rg' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix ErrorTarget: StatusCode: 404 ReasonPhrase: Not Found OperationID : 5de9f190-6186-4d7e-9081-2ecd093ef551 DEBUG: 3:58:09 AM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True]. DEBUG: 3:58:09 AM - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True]. DEBUG: 3:58:09 AM - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [True]. DEBUG: AzureQoSEvent: Module: Az.Compute:8.2.0; CommandName: Get-AzVMRunCommand; PSVersion: 7.4.5; IsSuccess: False; Duration: 00:00:00.3726287; SanitizeDuration: 00:00:00; Exception: The Resource 'Microsoft.Compute/virtualMachines/svr-mgmt-wsus-z1/runCommands/RunPowerShellScript' under resource group 'svr-mgmt-learn-rg' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix ErrorCode: ResourceNotFound ErrorMessage: The Resource 'Microsoft.Compute/virtualMachines/svr-mgmt-wsus-z1/runCommands/RunPowerShellScript' under resource group 'svr-mgmt-learn-rg' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix ErrorTarget: StatusCode: 404 ReasonPhrase: Not Found OperationID : 5de9f190-6186-4d7e-9081-2ecd093ef551; DEBUG: 3:58:09 AM - GetAzureVmRunCommand end processing.

nuwanpofficial commented 1 week ago

Also when I run the below command without specifying a specific RunCommand, I do not get any output.

image

But when I check the Run Commands from the console I can see them without any issues for the same VM.

image

Kindly help me to understand why is it behaving this way. Thank you.

microsoft-github-policy-service[bot] commented 1 week ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Drewm3, @TravisCragg-MSFT, @nikhilpatel909, @sandeepraichura, @hilaryw29, @GabstaMSFT, @ramankumarlive, @ushnaarshadkhan.