触发Azure Power从Power Automate创建MS Graph Teams beta

问题描述 投票:0回答:1

我有一个Azure函数,该函数根据查询变量创建一个新的Teams团队。当我从命令行卷曲或调用Invoke-RestMethod函数时,它将执行并创建团队。当我从Power Automate流程运行该功能时,该功能将失败。

我从Flow运行时收到的错误消息表明,对MS Graph Teams beta API的调用导致此问题,原因如下:

Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Exception while executing function: Functions.NewTeam
 ---> Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException: Result: Failure
Exception: System.Management.Automation.CmdletInvocationException: {
  "error": {
    "code": "NotFound",
    "message": "Failed to execute Templates backend request CreateTeamFromTemplateRequest. Request Url: https://teams.microsoft.com/fabric/templates/api/team, Request Method: POST, Response Status Code: NotFound, Response Headers: Strict-Transport-Security: max-age=2592000\r\nx-operationid: 14c6acc3601661469f152ac3d1d46b8a\r\nx-telemetryid: |14c6acc3601661469f152ac3d1d46b8a.7a1c5868_1.\r\nX-MSEdge-Ref: Ref A: 6259AF5FA1174BBCA9C2A70A448D15F4 Ref B: DB3EDGE1222 Ref C: 2020-04-01T05:38:26Z\r\nDate: Wed, 01 Apr 2020 05:38:26 GMT\r\n, ErrorMessage : {\"errors\":[{\"message\":\"Failed to execute request for MiddleTier CreateTeamS2SAsync. Status code: NotFound.\"}],\"operationId\":\"14c6acc3601661469f152ac3d1d46b8a\"}",
    "innerError": {
      "request-id": "37cb7b1c-ae0f-4191-8878-5a6d91578dd8",
      "date": "2020-04-01T05:38:26"
    }
  }
}

我必须在团队创建呼叫之前生成一个令牌,并且执行得很好。

我有固定的CORS,以允许跨域调用。 FLOW发出的其他呼叫按预期工作。仅此代码的最后一行失败,并且仅当从Flow调用时才出现:

            $params = @{
                Header        = Get-AzureMSGraphHeader @credential #calls the Graph endpoint and generates a token
                Method        = 'Post'
                Uri           = 'https://graph.microsoft.com/beta/teams'
            }
            $params.Body = @{
                displayName           = $TeamName
                description           = $TeamName
                "[email protected]" = "https://graph.microsoft.com/beta/teamsTemplates('standard')"
                '[email protected]'   = $Owners
                visibility            = 'Private'
            } | convertto-json
            Write-Information "Executing command"
            Invoke-AzureMSGraph @params #calls the graph endpoint with the body and header above

Invoke-AzureMSGraph是Invoke-RestMethod的包装。它将ContentType设置为'application / json'

任何在哪里寻找解决方案的指针都将不胜感激。

azure powershell azure-functions microsoft-graph power-automate
1个回答
0
投票

当完全相同的代码部署在新创建的Azure函数(在不同区域中)时,问题消失了。所有代码都相同。

在这种情况下,可部署的模板会派上用场。

© www.soinside.com 2019 - 2024. All rights reserved.