msgraph-sdk-powershell icon indicating copy to clipboard operation
msgraph-sdk-powershell copied to clipboard

Support long-running operations (New-MgTeam async operation is not handled within PowerShell SDK)

Open mhupfauer opened this issue 3 years ago • 1 comments

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

mhupfauer avatar Oct 10 '21 20:10 mhupfauer

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 of HttpResponseMessage.
    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.

peombwa avatar Oct 18 '21 17:10 peombwa

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.

peombwa avatar Apr 18 '23 22:04 peombwa

Similar to #2394

timayabi2020 avatar Dec 21 '23 08:12 timayabi2020

Closing this issue because the latest release deserializes headers and outputs them to a hash table. image

timayabi2020 avatar Feb 19 '24 06:02 timayabi2020

#2600 to resolve this

CarolKigoonya avatar Feb 19 '24 09:02 CarolKigoonya

Issue resolved in 2.15.0 release.

timayabi2020 avatar Feb 22 '24 13:02 timayabi2020

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.