Closed abatishchev closed 2 years ago
When you use the latest version of Az.Resource, AzAD feature is using MSGraph API. So you need to configure below 2 parameters when you add environment.
[-MicrosoftGraphEndpointResourceId <String>]
[-MicrosoftGraphUrl <String>]
@dingmeng-xue thanks for explanation. will update my local setup.
@dingmeng-xue I've set them to the same values:
GraphUrl : https://graph.ppe.windows.net/
GraphEndpointResourceId : https://graph.ppe.windows.net/
and
MicrosoftGraphEndpointResourceId https://graph.ppe.windows.net/
MicrosoftGraphUrl https://graph.ppe.windows.net/
Now when I call:
Get-AzADApplication -ApplicationId 93923bbd-d15c-4a3d-a81f-546112110fa2
I'm getting an error:
{
"odata.error": {
"code": "Request_DataContractVersionMissing",
"message": {
"lang": "en",
"value": "The specified api-version is invalid. The value must exactly match a supported version."
}
}
}
Debug output:
DEBUG: [CmdletBeginProcessing]: Starting command
DEBUG: CmdletBeginProcessing:
DEBUG: CmdletProcessRecordStart:
DEBUG: Client side pagination is enabled for this cmdlet
DEBUG: CmdletGetPipeline:
DEBUG: CmdletBeforeAPICall:
DEBUG: URLCreated: /applications?$filter=appId%20eq%20%2793923bbd-d15c-4a3d-a81f-546112110fa2%27
DEBUG: RequestCreated: /v1.0/applications?$filter=appId%20eq%20%2793923bbd-d15c-4a3d-a81f-546112110fa2%27
DEBUG: HeaderParametersAdded:
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
GET
Absolute Uri:
https://graph.ppe.windows.net/v1.0/applications?$filter=appId eq %2793923bbd-d15c-4a3d-a81f-546112110fa2%27
Headers:
x-ms-unique-id : 11
x-ms-client-request-id : 41d25330-0a0a-4cae-b815-c425e0557e61
CommandName : Az.MSGraph.internal\Get-AzADApplication
FullCommandName : Get-AzADApplication_List
ParameterSetName : __AllParameterSets
User-Agent : AzurePowershell/v7.5.0,PSVersion/v7.2.3,Az.MSGraph/5.6.0
Body:
DEBUG: BeforeCall:
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
BadRequest
Headers:
ocp-aad-diagnostics-server-name: UgaKXz1mgWlhPwesiRHyMV4LMKWIFD/BzqfJSEXiKZk=
request-id : b0febf0b-6781-4ed6-b684-01485a936962
client-request-id : 41d25330-0a0a-4cae-b815-c425e0557e61
X-Powered-By : ASP.NET
Strict-Transport-Security : max-age=31536000; includeSubDomains
Access-Control-Allow-Origin : *
Duration : 42810
Date : Tue, 17 May 2022 01:38:56 GMT
Body:
{
"odata.error": {
"code": "Request_DataContractVersionMissing",
"message": {
"lang": "en",
"value": "The specified api-version is invalid. The value must exactly match a supported version."
}
}
}
DEBUG: ResponseCreated:
DEBUG: BeforeResponseDispatch:
Get-AzADApplication_List: C:\Users\abatishchev\OneDrive\Documents\PowerShell\Modules\Az.Resources\5.6.0\MSGraph.Autorest\custom\Get-AzADApplication.ps1:219
Line |
219 | Az.MSGraph.internal\Get-AzADApplication @PSBoundParameters
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The server responded with a Request Error, Status: BadRequest
DEBUG: [Finally]: Getting exception 'Microsoft.Azure.Commands.Common.Exceptions.AzPSCloudException: InternalException' from response
DEBUG: Finally:
DEBUG: CmdletAfterAPICall:
DEBUG: [CmdletProcessRecordAsyncEnd]: Finish HTTP process
DEBUG: CmdletProcessRecordAsyncEnd:
DEBUG: CmdletProcessRecordEnd:
DEBUG: AzureQoSEvent: Module: Az.Resources:5.6.0; CommandName: Get-AzADApplication; PSVersion: 7.2.3; IsSuccess: False; Duration: 00:00:00.8826886; Exception: InternalException;
Hi Abatishchev, We don't own service or test environment. We cannot answer your question. You have to ask MSGraph team what version is supported. Azure PowerShell doesn't support configurable API version no matter in product environment or test environment. If version is not 1.0, you need to use Invoke-AzRestMethod
to send request to MSGraph directly.
When you use the latest version of Az.Resource, AzAD feature is using MSGraph API. So you need to configure below 2 parameters when you add environment.
[-MicrosoftGraphEndpointResourceId <String>]
[-MicrosoftGraphUrl <String>]
@dingmeng-xue this doesn't work for built-in environments:
Set-AzEnvironment -Name AzureCloud -MicrosoftGraphEndpointResourceId "https://graph.microsoft.com/" -MicrosoftGraphUrl "https://graph.microsoft.com/v1.0/" Set-AzEnvironment: Cannot change built-in or discovered environment AzureCloud.
I guess we can duplicate the built-in environments as a workaround but ideally we won't have to and they would already include the Azure Graph properties out of the box:
$graphEnabledEnv = Get-AzEnvironment -Name AzureCloud
$graphEnabledEnv.Name = "AzureCloudGraph"
$graphEnabledEnv | Add-AzEnvironment -MicrosoftGraphEndpointResourceId "https://graph.microsoft.com/" -MicrosoftGraphUrl "https://graph.microsoft.com/v1.0/"
Connect-AzAccount -Environment "AzureCloudGraph"
EDIT oh I think I get it now, the built-in environments already have these here:
(Get-AzEnvironment -Name AzureCloud).ExtendedProperties.MicrosoftGraphEndpointResourceId
(Get-AzEnvironment -Name AzureCloud).ExtendedProperties.MicrosoftGraphUrl
In case anyone has further issues with trying to use Get-AzAD cmdlets in Azure Dogfood its because the guidance above no longer works as the endpoints for Microsoft Graph are actually different: -GraphUrl "https://graph.ppe.windows.net/" -GraphEndpointResourceId "https://graph.ppe.windows.net/" -MicrosoftGraphEndpointResourceId "https://graph.microsoft-ppe.com/" -MicrosoftGraphUrl "https://graph.microsoft-ppe.com/v1.0/"
Description
Note: the target environment is Azure Dogfood:
I tried multiple cmdlets:
Regardless of the parameters passed (of lack of thereof), the error is always the same:
This issue is blocking me from performing development duties.
Issue script & Debug output
Environment data
Module versions
Error output
Attached: Resolve-AzError.txt