触发Azure Function从Power Automate创建MS Graph Teams测试版



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

从Flow运行时,我收到的错误消息表明,对MS Graph Teams测试版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=2592000rnx-operationid: 14c6acc3601661469f152ac3d1d46b8arnx-telemetryid: |14c6acc3601661469f152ac3d1d46b8a.7a1c5868_1.rnX-MSEdge-Ref: Ref A: 6259AF5FA1174BBCA9C2A70A448D15F4 Ref B: DB3EDGE1222 Ref C: 2020-04-01T05:38:26ZrnDate: Wed, 01 Apr 2020 05:38:26 GMTrn, 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
"template@odata.bind" = "https://graph.microsoft.com/beta/teamsTemplates('standard')"
'owners@odata.bind'   = $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函数上(在不同的区域(时,问题消失了。所有代码都是相同的。

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

最新更新