Azure / azure-cli

Azure Command-Line Interface
MIT License
4.03k stars 3.01k forks source link

az rest --headers not taken into account when $expand'ing Microsoft Graph API #26544

Open timmkrause opened 1 year ago

timmkrause commented 1 year ago

Describe the bug

When querying the Microsoft Graph API utilizing the $search parameter a special header needs to be set (see error message). When additionally applying $expand the correctly provided header does not seem to be taken into account anymore.

Command Name az rest

Errors:

Bad Request({"error":{"code":"Request_UnsupportedQuery","message":"Request with $search query parameter only works through MSGraph with a special request header: 'ConsistencyLevel: eventual'","innerError":{"date":"2023-05-26T07:16:39","request-id":"...","client-request-id":"..."}}})

To Reproduce:

$select = '$select=displayName'
$filterTest = '$search=\"displayName:MySearchString\"'
$expand = '$expand=appRoleAssignedTo'

✔ Works:

az rest `
    --method GET `
    --headers ConsistencyLevel=eventual `
    --uri "https://graph.microsoft.com/v1.0/servicePrincipals" `
    --url-parameters $filterTest $select

❌ Does not work because of adding $expand:

az rest `
    --method GET `
    --headers ConsistencyLevel=eventual `
    --uri "https://graph.microsoft.com/v1.0/servicePrincipals" `
    --url-parameters $filterTest $select $expand

--verbose shows that the header is set correctly.

Expected Behavior

Should work with $expanding as well.

Environment Summary

Windows-10-10.0.19045-SP0
Python 3.10.10
Installer: MSI

azure-cli 2.49.0

Extensions:
account 0.2.5
containerapp 0.3.31

Dependencies:
msal 1.20.0
azure-mgmt-resource 22.0.0

Additional Context

Maybe $expanding leads to subsequent requests where the header is not being forwarded to anymore?

yonzhan commented 1 year ago

Thank you for opening this issue, we will look into it.

navba-MSFT commented 1 year ago

Adding Service team to look into this.