msgraph-sdk-powershell
msgraph-sdk-powershell copied to clipboard
Support long-running operations (New-MgTeam async operation is not handled within PowerShell SDK)
The teamsAsyncOperation returned by POST /beta/teams is not handled within the PowerShell SDK.
The documentation however mentions the return of an object typed as Microsoft.Graph.PowerShell.Models.IMicrosoftGraphTeam
According to the API docs, teamAysncOperation is returned in the location header when a team is created since the request is non-committal (returns 202 status code). The request itself returns no response object.
The SDK does not currently deserialize headers. Your options at the moment are:
- Use
New-MgTeam @params -Debug
to log location header to the debug stream. - Use
Invoke-MgGraphRequest
with an-OutputType
ofHttpResponseMessage
.Invoke-MgGraphRequest -Uri https://graph.microsoft.com/v1.0/teams -Body @params -Method POST -OutputType HttpResponseMessage
I'll keep this issue open a feature request for us to:
- Support long-running operations natively in the SDK.
- Deserialize response headers to a global variable - https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/630.
Update on the issue. The code generator now supports LRO.
To have LRO support, we will need to set x-ms-long-running-operation: true
on OpenAPI operations that support LRO. For example:
/teams:
post:
tags:
- teams.team
summary: Create team
description: Create a new team.
operationId: teams.team_CreateTeam
x-ms-long-running-operation: true # This needs to be added
requestBody:
description: New entity
content:
application/json:
schema:
$ref: '#/components/schemas/microsoft.graph.team'
required: true
responses:
'2XX':
description: Created entity
content:
application/json:
schema:
$ref: '#/components/schemas/microsoft.graph.team'
default:
$ref: '#/components/responses/error'
x-ms-docs-operation-type: operation
The work to add LRO support in the SDK will be scheduled post Microsoft Graph PowerShell v2.
Progress bars on LRO commands will be available in AutoREST.PowerShell v4 - https://github.com/Azure/autorest.powershell/pull/1013.
Similar to #2394
Closing this issue because the latest release deserializes headers and outputs them to a hash table.
#2600 to resolve this
Issue resolved in 2.15.0 release.
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.