Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.27k stars 3.87k forks source link

Invoke-AzRestMethod Deconstructed Parameters when using "GET" ignores payload #26755

Open JustinGrote opened 5 days ago

JustinGrote commented 5 days ago

Description

Using Invoke-AzRestMethod with GET and payload completely ignores it. It should take the hashtable payload and append it as query parameters, in the same way Invoke-Restmethod does with -Body.

In the below script, the payload parameters are not appended as query parameters, they are just ignored. Therefore the query below there is no way to do without doing the -Uri method.

RequestURI generated for the below is https://management.azure.com/subscriptions/52487fb1-7325-4ec9-9bb0-a9079e62d255/resourceGroups/PRTGDocker/providers/Microsoft.Compute/virtualMachines?api-version=2024-03-01 which is missing the expand query parameter.

Issue script & Debug output

$azrmParams = @{
    Method  = 'GET'
    SubscriptionId = '52487fb1-7325-4ec9-9bb0-a9079e62d255'
    ResourceGroupName = 'PRTGDocker'
    ResourceProviderName = 'Microsoft.Compute'
    ResourceType         = 'virtualMachines'
    ApiVersion = '2024-03-01'
    Payload = @{
        '$expand' = 'instanceView'
    }
}

Invoke-AzRestMethod @azrmParams
DEBUG: 11:10:24 PM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 11:10:24 PM - InvokeAzRestMethodCommand begin processing with ParameterSet 'ByParameters'.
DEBUG: 11:10:24 PM - using account id 'justingrote@gmail.com'...
DEBUG: 11:10:24 PM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: [Common.Authentication]: Authenticating using Account: 'justingrote@gmail.com', environment: 'AzureCloud', tenant: '3344d4f9-bb09-4c2b-ac20-07405f5532f3'
DEBUG: 11:10:24 PM - [ConfigManager] Got nothing from [DisableInstanceDiscovery], Module = [], Cmdlet = []. Returning default value [False].
DEBUG: 11:10:24 PM - [ConfigManager] Got nothing from [EnableLoginByWam], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 11:10:24 PM - [SilentAuthenticator] Calling SharedTokenCacheCredential.GetTokenAsync - TenantId:'3344d4f9-bb09-4c2b-ac20-07405f5532f3', Scopes:'https://management.core.windows.net//.default', AuthorityHost:'https://login.microsoftonline.com/', UserId:'justingrote@gmail.com'
DEBUG: SharedTokenCacheCredential.GetToken invoked. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId:
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z - 3e188fc7-e263-4c63-910a-f689fd2ae3e3] IsLegacyAdalCacheEnabled: yes       
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z - 3e188fc7-e263-4c63-910a-f689fd2ae3e3] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z - 3e188fc7-e263-4c63-910a-f689fd2ae3e3] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z - 3e188fc7-e263-4c63-910a-f689fd2ae3e3] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z - 3e188fc7-e263-4c63-910a-f689fd2ae3e3] IsLegacyAdalCacheEnabled: yes       
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z - 3e188fc7-e263-4c63-910a-f689fd2ae3e3] IsLegacyAdalCacheEnabled: yes       
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [Runtime] WAM supported OS.
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [RuntimeBroker] ListWindowsWorkAndSchoolAccounts option was not enabled.   
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z - 05eb9011-6127-40ba-82ff-a3b006f878b6] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] Found 2 cache accounts and 0 broker accounts
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] Returning 2 accounts
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z - 6ed0bf6d-8811-4135-90e8-5ac86451a08e] MSAL MSAL.CoreCLR with assembly version '4.61.3.0'. CorrelationId(6ed0bf6d-8811-4135-90e8-5ac86451a08e)
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z - 6ed0bf6d-8811-4135-90e8-5ac86451a08e] === AcquireTokenSilent Parameters ===
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z - 6ed0bf6d-8811-4135-90e8-5ac86451a08e] LoginHint provided: False
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z - 6ed0bf6d-8811-4135-90e8-5ac86451a08e] Account provided: True
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z - 6ed0bf6d-8811-4135-90e8-5ac86451a08e] ForceRefresh: False
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z - 6ed0bf6d-8811-4135-90e8-5ac86451a08e]
=== 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 - True
HomeAccountId - False
CorrelationId - 6ed0bf6d-8811-4135-90e8-5ac86451a08e
UserAssertion set: False
LongRunningOboCacheKey set: False
Region configured:

DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z - 6ed0bf6d-8811-4135-90e8-5ac86451a08e] === Token Acquisition (SilentRequest) started:
         Scopes: https://management.core.windows.net//.default
        Authority Host: login.microsoftonline.com
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z - 6ed0bf6d-8811-4135-90e8-5ac86451a08e] Broker is configured and enabled, attempting to use broker instead.
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [Runtime] WAM supported OS.
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z - 6ed0bf6d-8811-4135-90e8-5ac86451a08e] Can invoke broker. Will attempt to acquire token with broker.
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0001]     WARNING SetAuthorityUri:78      Initializing authority from URI 'https://login.microsoftonline.com/3344d4f9-bb09-4c2b-ac20-07405f5532f3/' without authority type, defaulting to MsSts
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0008]     INFO    LogTelemetryData:422    Printing Telemetry for Correlation ID: 6ed0bf6d-8811-4135-90e8-5ac86451a08e
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0008]     INFO    LogTelemetryData:430    Key: start_time, Value: 2024-11-25T07:10:24.000Z
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0008]     INFO    LogTelemetryData:430    Key: api_name, Value: ReadAccountById
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0008]     INFO    LogTelemetryData:430    Key: was_request_throttled, Value: false
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0008]     INFO    LogTelemetryData:430    Key: authority_type, Value: Unknown
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0008]     INFO    LogTelemetryData:430    Key: msal_version, Value: 1.1.0+local
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0008]     INFO    LogTelemetryData:430    Key: correlation_id, Value: 6ed0bf6d-8811-4135-90e8-5ac86451a08e
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0008]     INFO    LogTelemetryData:430    Key: broker_app_used, Value: false
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0008]     INFO    LogTelemetryData:430    Key: stop_time, Value: 2024-11-25T07:10:24.000Z
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0008]     INFO    LogTelemetryData:430    Key: msalruntime_version, Value: 0.16.2
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0008]     INFO    LogTelemetryData:430    Key: is_successful, Value: true
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0008]     INFO    LogTelemetryData:430    Key: request_duration, Value: 0
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0008]     INFO    SetCorrelationId:258    Set correlation ID: 6ed0bf6d-8811-4135-90e8-5ac86451a08e
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0008]     INFO    EnqueueBackgroundRequest:1000   The original authority is 'https://login.microsoftonline.com/3344d4f9-bb09-4c2b-ac20-07405f5532f3'
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0008]     INFO    ModifyAndValidateAuthParameters:219     Additional query parameter added successfully. Key: '(pii)' Value: '(pii)'
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0008]     INFO    ModifyAndValidateAuthParameters:243     Authority Realm: 3344d4f9-bb09-4c2b-ac20-07405f5532f3
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0008]     WARNING TryEnqueueMsaDeviceCredentialAcquisitionAndContinue:1052   MsaDeviceOperationProvider is not available. Not attempting to register the device.
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0003]     INFO    StorageTokenResponse:84 StorageTokenResponse account constructor invoked. This is only expected in Runtime flows
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0003]     INFO    LogTelemetryData:422    Printing Telemetry for Correlation ID: 6ed0bf6d-8811-4135-90e8-5ac86451a08e
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0003]     INFO    LogTelemetryData:430    Key: start_time, Value: 2024-11-25T07:10:24.000Z
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0003]     INFO    LogTelemetryData:430    Key: api_name, Value: AcquireTokenSilently
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0003]     INFO    LogTelemetryData:430    Key: was_request_throttled, Value: false
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0003]     INFO    LogTelemetryData:430    Key: authority_type, Value: MSA
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0003]     INFO    LogTelemetryData:430    Key: access_token_expiry_time, Value: 2024-11-25T08:01:42.000Z
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0003]     INFO    LogTelemetryData:430    Key: read_token, Value: ID|AT
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0003]     INFO    LogTelemetryData:430    Key: msal_version, Value: 1.1.0+local
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0003]     INFO    LogTelemetryData:430    Key: client_id, Value: 1950a258-227b-4e31-a9cf-717495945fc2
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0003]     INFO    LogTelemetryData:430    Key: correlation_id, Value: 6ed0bf6d-8811-4135-90e8-5ac86451a08e
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0003]     INFO    LogTelemetryData:430    Key: broker_app_used, Value: false
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0003]     INFO    LogTelemetryData:430    Key: stop_time, Value: 2024-11-25T07:10:24.000Z
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0003]     INFO    LogTelemetryData:430    Key: msalruntime_version, Value: 0.16.2
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0003]     INFO    LogTelemetryData:430    Key: original_authority, Value: https://login.microsoftonline.com/3344d4f9-bb09-4c2b-ac20-07405f5532f3
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0003]     INFO    LogTelemetryData:430    Key: request_eligible_for_broker, Value: true
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0003]     INFO    LogTelemetryData:430    Key: additional_query_parameters_count, Value: 1
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0003]     INFO    LogTelemetryData:430    Key: storage_read, Value: DAC|DAT|DID
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0003]     INFO    LogTelemetryData:430    Key: auth_flow, Value: AT  
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0003]     INFO    LogTelemetryData:430    Key: is_successful, Value: true
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0003]     INFO    LogTelemetryData:430    Key: authorization_type, Value: WindowsIntegratedAuth
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0003]     INFO    LogTelemetryData:430    Key: request_duration, Value: 3
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0003]     INFO    LogTelemetryData:435    Printing Execution Flow:   
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [MSAL:0003]     INFO    LogTelemetryData:443    {"t":"4s7uc","tid":8,"ts":0,"l":2},{"t":"4sufd","tid":8,"ts":0,"s":2,"l":2},{"t":"4swgg","tid":8,"ts":0,"s":6,"l":2},{"t":"4swgf","tid":8,"ts":0,"s":1,"l":2},{"t":"4swgi","tid":3,"ts":0,"s":6,"l":2},{"t":"8b2yn","tid":3,"ts":0,"l":2},{"t":"8dqkx","tid":3,"ts":0,"l":2},{"t":"8dqik","tid":3,"ts":0,"l":2},{"t":"4q2di","tid":3,"ts":0,"l":2},{"t":"4qnng","tid":3,"ts":0,"l":2,"a":2,"ie":0},{"t":"4qnnf","tid":3,"ts":2,"l":2,"a":2,"ie":1},{"t":"8dqit","tid":3,"ts":2,"l":2},{"t":"8b2ht","tid":3,"ts":2,"l":2},{"t":"4qnno","tid":3,"ts":2,"l":2,"a":2,"ie":0},{"t":"4qnnn","tid":3,"ts":3,"l":2,"a":2,"ie":1},{"t":"6xuag","tid":3,"ts":4,"l":2}
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z] [RuntimeBroker] WAM response status success
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z - 6ed0bf6d-8811-4135-90e8-5ac86451a08e] Checking MsalTokenResponse returned from broker.
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z - 6ed0bf6d-8811-4135-90e8-5ac86451a08e] Success. Response contains an access token.
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z - 6ed0bf6d-8811-4135-90e8-5ac86451a08e] Checking client info returned from the server..
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z - 6ed0bf6d-8811-4135-90e8-5ac86451a08e] Saving token response to cache..    
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z - 6ed0bf6d-8811-4135-90e8-5ac86451a08e] [Instance Discovery] Instance discovery is enabled and will be performed
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z - 6ed0bf6d-8811-4135-90e8-5ac86451a08e] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z - 6ed0bf6d-8811-4135-90e8-5ac86451a08e] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z - 6ed0bf6d-8811-4135-90e8-5ac86451a08e] [SaveTokenResponseAsync] Saving Id Token and Account in cache ...
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z - 6ed0bf6d-8811-4135-90e8-5ac86451a08e]
        === Token Acquisition finished successfully:
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z - 6ed0bf6d-8811-4135-90e8-5ac86451a08e]  AT expiration time: 11/25/2024 8:01:41 AM +00:00, scopes: https://management.core.windows.net//.default https://management.core.windows.net//user_impersonation. source: Broker
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.10 Microsoft Windows 10.0.22635 [2024-11-25 07:10:24Z - 6ed0bf6d-8811-4135-90e8-5ac86451a08e] Fetched access token from host login.microsoftonline.com.
DEBUG: SharedTokenCacheCredential.GetToken succeeded. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId:  ExpiresOn: 2024-11-25T08:01:41.0720219+00:00     
DEBUG: [Common.Authentication]: Received token with LoginType 'User', Tenant: '3344d4f9-bb09-4c2b-ac20-07405f5532f3', UserId: 'justingrote@gmail.com'
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.azure.com/subscriptions/52487fb1-7325-4ec9-9bb0-a9079e62d255/resourceGroups/PRTGDocker/providers/Microsoft.Compute/virtualMachines?api-version=2024-03-01       

Headers:
Accept-Language               : en-US
x-ms-client-request-id        : d9d43e61-02e5-4726-98b9-b96ce5dccb4b

Body:

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

Status Code:
OK

Headers:
Cache-Control                 : no-cache
Pragma                        : no-cache
x-ms-ratelimit-remaining-resource: Microsoft.Compute/HighCostGetSubscriptionMaximum;899
x-ms-need-to-refresh-epl-cache: False
Strict-Transport-Security     : max-age=31536000; includeSubDomains
x-ms-request-id               : 3dfb93b4-6911-4767-90f1-04e0ced1a77d
x-ms-ratelimit-remaining-subscription-reads: 249
x-ms-ratelimit-remaining-subscription-global-reads: 3749
x-ms-correlation-request-id   : 60412b88-6fc8-4faa-9931-0f3b857b3bf5
x-ms-routing-request-id       : WESTUS2:20241125T071024Z:60412b88-6fc8-4faa-9931-0f3b857b3bf5
X-Content-Type-Options        : nosniff
X-Cache                       : CONFIG_NOCACHE
X-MSEdge-Ref                  : Ref A: 7F68AF1B2D6342B0BB80E31D71076938 Ref B: CO6AA3150217035 Ref C: 2024-11-25T07:10:24Z
Date                          : Mon, 25 Nov 2024 07:10:23 GMT

Body:
{
  "value": [
    {
      "name": "prtgdocker",
      "id": "/subscriptions/52487fb1-7325-4ec9-9bb0-a9079e62d255/resourceGroups/PRTGDocker/providers/Microsoft.Compute/virtualMachines/prtgdocker",
      "type": "Microsoft.Compute/virtualMachines",
      "location": "westus3",
      "tags": {
        "Test": "Tag"
      },
      "properties": {
        "hardwareProfile": {
          "vmSize": "Standard_F4s_v2"
        },
        "provisioningState": "Succeeded",
        "vmId": "6a4c5ed1-09b7-4469-9c27-4df04c4ae76f",
        "additionalCapabilities": {
          "hibernationEnabled": false
        },
        "storageProfile": {
          "imageReference": {
            "publisher": "MicrosoftWindowsServer",
            "offer": "WindowsServer",
            "sku": "2022-datacenter-azure-edition-hotpatch",
            "version": "latest",
            "exactVersion": "20348.2227.240206"
          },
          "osDisk": {
            "osType": "Windows",
            "name": "prtgdocker_OsDisk_1_cc46676ac8fe47879771504a058e6678",
            "createOption": "FromImage",
            "caching": "ReadWrite",
            "managedDisk": {
              "id": "/subscriptions/52487fb1-7325-4ec9-9bb0-a9079e62d255/resourceGroups/PRTGDOCKER/providers/Microsoft.Compute/disks/prtgdocker_OsDisk_1_cc46676ac8fe47879771504a058e6678"
            },
            "deleteOption": "Delete"
          },
          "dataDisks": [],
          "diskControllerType": "SCSI"
        },
        "osProfile": {
          "computerName": "prtgdocker",
          "adminUsername": "jgrote",
          "windowsConfiguration": {
            "provisionVMAgent": true,
            "enableAutomaticUpdates": true,
            "patchSettings": {
              "patchMode": "AutomaticByPlatform",
              "automaticByPlatformSettings": {
                "rebootSetting": "IfRequired",
                "bypassPlatformSafetyChecksOnUserSchedule": false
              },
              "assessmentMode": "ImageDefault",
              "enableHotpatching": true
            },
            "enableVMAgentPlatformUpdates": false
          },
          "secrets": [],
          "allowExtensionOperations": true,
          "requireGuestProvisionSignal": true
        },
        "securityProfile": {
          "uefiSettings": {
            "secureBootEnabled": true,
            "vTpmEnabled": true
          },
          "securityType": "TrustedLaunch"
        },
        "networkProfile": {
          "networkInterfaces": [
            {
              "id": "/subscriptions/52487fb1-7325-4ec9-9bb0-a9079e62d255/resourceGroups/PRTGDocker/providers/Microsoft.Network/networkInterfaces/prtgdocker813_z1",
              "properties": {
                "deleteOption": "Delete"
              }
            }
          ]
        },
        "diagnosticsProfile": {
          "bootDiagnostics": {
            "enabled": true
          }
        },
        "licenseType": "Windows_Server",
        "priority": "Spot",
        "evictionPolicy": "Deallocate",
        "billingProfile": {
          "maxPrice": -1.0
        },
        "timeCreated": "2024-02-14T13:35:36.940453-08:00"
      },
      "etag": "\"15\"",
      "zones": [
        "1"
      ]
    }
  ]
}

DEBUG: 11:10:24 PM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].

StatusCode : 200
Content    : {
               "value": [
                 {
                   "name": "prtgdocker",
                   "id": "/subscriptions/52487fb1-7325-4ec9-9bb0-a9079e62d255/resourceGroups/PRTGDocker/providers/Microsoft.Compute/virtualMachines/prtgdocker",
                   "type": "Microsoft.Compute/virtualMachines",
                   "location": "westus3",
                   "tags": {
                     "Test": "Tag"
                   },
                   "properties": {
                     "hardwareProfile": {
                       "vmSize": "Standard_F4s_v2"
                     },
                     "provisioningState": "Succeeded",
                     "vmId": "6a4c5ed1-09b7-4469-9c27-4df04c4ae76f",
                     "additionalCapabilities": {
                       "hibernationEnabled": false
                     },
                     "storageProfile": {
                       "imageReference": {
                         "publisher": "MicrosoftWindowsServer",
                         "offer": "WindowsServer",
                         "sku": "2022-datacenter-azure-edition-hotpatch",
                         "version": "latest",
                         "exactVersion": "20348.2227.240206"
                       },
                       "osDisk": {
                         "osType": "Windows",
                         "name": "prtgdocker_OsDisk_1_cc46676ac8fe47879771504a058e6678",
                         "createOption": "FromImage",
                         "caching": "ReadWrite",
                         "managedDisk": {
                           "id": "/subscriptions/52487fb1-7325-4ec9-9bb0-a9079e62d255/resourceGroups/PRTGDOCKER/providers/Microsoft.Compute/disks/prtgdocker_OsDisk_1_cc46676ac8fe 
             47879771504a058e6678"
                         },
                         "deleteOption": "Delete"
                       },
                       "dataDisks": [],
                       "diskControllerType": "SCSI"
                     },
                     "osProfile": {
                       "computerName": "prtgdocker",
                       "adminUsername": "jgrote",
                       "windowsConfiguration": {
                         "provisionVMAgent": true,
                         "enableAutomaticUpdates": true,
                         "patchSettings": {
                           "patchMode": "AutomaticByPlatform",
                           "automaticByPlatformSettings": {
                             "rebootSetting": "IfRequired",
                             "bypassPlatformSafetyChecksOnUserSchedule": false
                           },
                           "assessmentMode": "ImageDefault",
                           "enableHotpatching": true
                         },
                         "enableVMAgentPlatformUpdates": false
                       },
                       "secrets": [],
                       "allowExtensionOperations": true,
                       "requireGuestProvisionSignal": true
                     },
                     "securityProfile": {
                       "uefiSettings": {
                         "secureBootEnabled": true,
                         "vTpmEnabled": true
                       },
                       "securityType": "TrustedLaunch"
                     },
                     "networkProfile": {
                       "networkInterfaces": [
                         {
                           "id": "/subscriptions/52487fb1-7325-4ec9-9bb0-a9079e62d255/resourceGroups/PRTGDocker/providers/Microsoft.Network/networkInterfaces/prtgdocker813_z1",   
                           "properties": {
                             "deleteOption": "Delete"
                           }
                         }
                       ]
                     },
                     "diagnosticsProfile": {
                       "bootDiagnostics": {
                         "enabled": true
                       }
                     },
                     "licenseType": "Windows_Server",
                     "priority": "Spot",
                     "evictionPolicy": "Deallocate",
                     "billingProfile": {
                       "maxPrice": -1.0
                     },
                     "timeCreated": "2024-02-14T13:35:36.940453-08:00"
                   },
                   "etag": "\"15\"",
                   "zones": [
                     "1"
                   ]
                 }
               ]
             }
Headers    : {
               "Cache-Control": "no-cache",
               "Pragma": "no-cache",
               "x-ms-ratelimit-remaining-resource": "Microsoft.Compute/HighCostGetSubscriptionMaximum;899",
               "x-ms-need-to-refresh-epl-cache": "False",
               "Strict-Transport-Security": "max-age=31536000; includeSubDomains",
               "x-ms-request-id": "3dfb93b4-6911-4767-90f1-04e0ced1a77d",
               "x-ms-ratelimit-remaining-subscription-reads": "249",
               "x-ms-ratelimit-remaining-subscription-global-reads": "3749",
               "x-ms-correlation-request-id": "60412b88-6fc8-4faa-9931-0f3b857b3bf5",
               "x-ms-routing-request-id": "WESTUS2:20241125T071024Z:60412b88-6fc8-4faa-9931-0f3b857b3bf5",
               "X-Content-Type-Options": "nosniff",
               "X-Cache": "CONFIG_NOCACHE",
               "X-MSEdge-Ref": "Ref A: 7F68AF1B2D6342B0BB80E31D71076938 Ref B: CO6AA3150217035 Ref C: 2024-11-25T07:10:24Z",
               "Date": "Mon, 25 Nov 2024 07:10:23 GMT"
             }
Method     : GET
RequestUri : https://management.azure.com/subscriptions/52487fb1-7325-4ec9-9bb0-a9079e62d255/resourceGroups/PRTGDocker/providers/Microsoft.Compute/virtualMachines?api-version=202 
             4-03-01
Version    : 1.1

DEBUG: 11:10:24 PM - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 11:10:24 PM - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: AzureQoSEvent:  Module: Az.Accounts:3.0.4; CommandName: Invoke-AzRestMethod; PSVersion: 7.4.6; IsSuccess: True; Duration: 00:00:00.2992462; SanitizeDuration: 00:00:00.0013755
DEBUG: 11:10:24 PM - [ConfigManager] Got nothing from [EnableDataCollection], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 11:10:24 PM - InvokeAzRestMethodCommand end processing.

Environment data

Name                           Value
----                           -----
PSVersion                      7.4.6
PSEdition                      Core
GitCommitId                    7.4.6
OS                             Microsoft Windows 10.0.22635
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     3.0.4                 Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault…}

Error output

No Error
VeryEarly commented 2 days ago

please see spec of this API: https://github.com/Azure/azure-rest-api-specs/blob/main/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/virtualMachine.json#L1152-L1165

expand is a query parameter not payload

JustinGrote commented 1 day ago

@VeryEarly show me how I do this with Invoke-Restmethod syntax without using URI then. That's my point. Whether it's done in -Payload or as a new parameter, I don't care.