-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Payload for authV2 running in Azure DevOps Pipelines invalid #30695
Comments
Hi @Tom-CT, 2.67.0 is not the latest Azure CLI(2.68.0). If you haven't already attempted to do so, please upgrade to the latest Azure CLI version by following https://learn.microsoft.com/en-us/cli/azure/update-azure-cli. |
Thank you for opening this issue, we will look into it. |
I don't think this is related to The values of
When executed locally in PowerShell 7.4.6 on Windows,
In CMD, the escaping also works as expected:
However, in PowerShell on Linux, CLI is receiving
This matches your observation on Azure DevOps Pipelines, so please check if you are using a Linux agent. Actually, instead of escaping the JSON and passing it as a shell parameter, I highly recommend following https://github.com/Azure/azure-cli/blob/dev/doc/quoting-issues-with-powershell.md#best-practice-use-file-input-for-json to use
This bypasses shell quoting and ensures the JSON is passed to Azure CLI untouched. |
Thanks, using stdin definitely makes it easier and helped solve my issue |
@Tom-CT, here are some links to published docs that talk about quoting differences between environments: |
Describe the bug
I am trying to use az ad app update --id [appId] --set api=[json] to add a scope to an app registration. Locally I am using powershell 7.4.6, cli 2.67.0 and authV2 0.1.3 on win 24H2.
The following is the code used to reproduce the issue:
If I run this locally, I get a 200 and adding the --debug flag to the az command, I can see there's a payload that looks like:
{"api": {"oauth2PermissionScopes": [{"adminConsentDescription": "user impersonation", "adminConsentDisplayName": "user_impersonation", "id": "[some guid]", "isEnabled": "true", "type": "User", "userConsentDescription": "user impersonation", "userConsentDisplayName": "user_impersonation", "value": "user_impersonation"}]}}
If I run the same thing in an Azure Pipeline on a windows-latest agent, I get a 400 and can see it has a payload that looks like:
{"api": "{\"oauth2PermissionScopes\":[{\"adminConsentDescription\":\"user", "impersonation\",\"adminConsentDisplayName\":\"user_impersonation\",\"id\":\"[some guid]\",\"isEnabled\":\"true\",\"type\":\"User\",\"userConsentDescription\":\"user": "", "impersonation\",\"userConsentDisplayName\":\"user_impersonation\",\"value\":\"user_impersonation\"}]}": ""}
I have added additional logging in and can confirm that $updateJson and $escapedJson are identical when running locally and in the pipeline. I have also checked that the service connection that the pipeline is using for the AzureCLI@2 task this is running in has sufficient privileges to view and modify registered applications.
The only difference I can really see is that I have the authV2 extension installed locally, but to ensure that it is being used by the pipeline, I have this towards the top of my script:
az extension add --name authV2
Related command
az ad app update --id [appId] --set api="{\"oauth2PermissionScopes\":[{\"adminConsentDescription\":\"user impersonation\",\"adminConsentDisplayName\":\"user_impersonation\",\"id\":\"[some guid]\",\"isEnabled\":\"true\",\"type\":\"User\",\"userConsentDescription\":\"user impersonation\",\"userConsentDisplayName\":\"user_impersonation\",\"value\":\"user_impersonation\"}]}"
Errors
{"error":{"code":"BadRequest","message":"Property api in payload has a value that does not match schema.","innerError":{"date":"2025-01-22T12:07:30","request-id":"86c0e7aa-05c1-4ffa-b2da-e6e55edfe931","client-request-id":"86c0e7aa-05c1-4ffa-b2da-e6e55edfe931"}}}
Issue script & Debug output
Expected behavior
authV2 should have a payload of when running under the AzureCLI@2 task:
{"api": {"oauth2PermissionScopes": [{"adminConsentDescription": "user impersonation", "adminConsentDisplayName": "user_impersonation", "id": "[some guid]", "isEnabled": "true", "type": "User", "userConsentDescription": "user impersonation", "userConsentDisplayName": "user_impersonation", "value": "user_impersonation"}]}}
Environment Summary
azure-cli 2.67.0 *
core 2.67.0 *
telemetry 1.1.0
Extensions:
account 0.2.5
authV2 0.1.3
datafactory 1.0.2
Dependencies:
msal 1.31.0
azure-mgmt-resource 23.1.1
Python location 'C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe'
Extensions directory 'C:\Users\Tom.Allen.azure\cliextensions'
Python (Windows) 3.12.7 (tags/v3.12.7:0b05ead, Oct 1 2024, 03:06:41) [MSC v.1941 64 bit (AMD64)]
Additional context
No response
The text was updated successfully, but these errors were encountered: