Not sure if this is just a question because of what am i doing wrong, or there is a bug here.
My code is grabbing results from Azure Log Analytics with a complicated query, and I'm using az rest. From within a PowerShell 7 window I'm able to make the call and retrieve results. However when I call the PowerShell script from within an Azure Pipeline I receive an error when it's reading in the body.
This is my query json file. It is reading in the AADServicePrincipalSignInLogs and looking for Apps that are signing in with ADAL.
Below is the call using az rest. The $WorkspaceResourceId looks like /subscriptions/<subscriptionid>/resourcegroups/<resourcegroup-name>/providers/microsoft.operationalinsights/workspaces/<loganalyticsname>
az rest --method POST --url "https://management.azure.com$WorkspaceResourceId/api/query?api-version=2017-01-01-preview"--body `@adalquery.json
The exact same code running through a pipeline
2021-10-20T14:20:22.6899388Z [command]C:\Windows\system32\cmd.exe /D /S /C ""C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd" --version"
2021-10-20T14:20:28.9711113Z WARNING: You have 2 updates available. Consider updating your CLI installation with 'az upgrade'
2021-10-20T14:20:28.9712365Z azure-cli 2.28.0 *
2021-10-20T14:20:28.9902230Z
2021-10-20T14:20:28.9903079Z
2021-10-20T14:20:28.9935086Z Please let us know how we are doing: https://aka.ms/azureclihats
2021-10-20T14:20:28.9935879Z core 2.28.0 *
2021-10-20T14:20:29.0000573Z and let us know if you're interested in trying out our newest features: https://aka.ms/CLIUXstudy
2021-10-20T14:20:29.0001477Z telemetry 1.0.6
2021-10-20T14:20:29.0110459Z
2021-10-20T14:20:29.0135748Z Extensions:
2021-10-20T14:20:29.0703479Z azure-devops 0.20.0
....
2021-10-20T14:20:43.7956799Z [command]C:\Windows\system32\cmd.exe /D /S /C ""C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd" account set --subscription ae68c399-6a9a-467b-9192-61e294da12e1"
2021-10-20T14:20:44.1843402Z [command]"C:\Program Files\PowerShell\7\pwsh.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'D:\a\_temp\azureclitaskscript1634739622650.ps1'"
2021-10-20T14:20:44.8151625Z Getting Query...
2021-10-20T14:20:45.0358591Z https://management.azure.com/subscriptions/***/resourcegroups/***/providers/microsoft.operationalinsights/workspaces/***/api/query?api-version=2017-01-01-preview
2021-10-20T14:20:53.1872813Z ERROR: Bad Request({"error":{"message":"The request had some invalid properties","code":"BadArgumentError","correlationId":"9479b99a-698b-486c-9fdb-b6d79f97f6d9","details":[{"code":"InvalidJsonBody","message":"Unexpected token @ in JSON at position 0","target":null}],"innererror":{"code":"QueryValidationError","message":"Failed parsing the query"}}})
I guess this is because pipelines create a temporary Powershell file D:\a\_temp\azureclitaskscript1634739622650.ps1
My YAML file is below. As you can see it's using Windows.
Not sure if this is just a question because of what am i doing wrong, or there is a bug here.
My code is grabbing results from Azure Log Analytics with a complicated query, and I'm using az rest. From within a PowerShell 7 window I'm able to make the call and retrieve results. However when I call the PowerShell script from within an Azure Pipeline I receive an error when it's reading in the body.
This is my query json file. It is reading in the AADServicePrincipalSignInLogs and looking for Apps that are signing in with ADAL.
Below is the call using
az rest
. The $WorkspaceResourceId looks like/subscriptions/<subscriptionid>/resourcegroups/<resourcegroup-name>/providers/microsoft.operationalinsights/workspaces/<loganalyticsname>
The exact same code running through a pipeline
I guess this is because pipelines create a temporary Powershell file
D:\a\_temp\azureclitaskscript1634739622650.ps1
My YAML file is below. As you can see it's using Windows.
Has anyone had this problem, and got around it (without writing the script in BASH).