我可以运行需要运行 1 小时以上的 Azure 函数吗?

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

我可以运行需要运行 1 小时以上的预定 ps Azure 函数吗?我已经尝试过消费和高级计划,但预定的 Azure 功能由于超时而卡住了。

更新

我尝试让 AAD 中的所有小组成员都加入。我运行这个 ms graph url:

https://graph.microsoft.com/v1.0/groups?$top=999&$expand=members

但是因为群组成员有 999 人,所以我需要使用寻呼功能。请参阅下面的代码片段:

$allPages = @()
    $items = (Invoke-RestMethod -Method 'Get' -Uri 'https://graph.microsoft.com/v1.0/groups?$top=999&$expand=members' -Headers $authHeader  -ContentType 'Application/Json') 
    $allPages += $items.value

    $index = 0
    if ($items.'@odata.nextLink') {
            do {
                  $index++
                  "Index counter: $index"

                  $token = (Get-AzAccessToken -ResourceUrl "https://graph.microsoft.com/").Token
                  $authHeader = @{Authorization = "Bearer $token"}

                  $items = (Invoke-RestMethod -Method 'Get' -Uri $items.'@odata.nextLink' -Headers $authHeader  -ContentType 'Application/Json')
                  $allPages += $items.value
             } until (
                 !$items.'@odata.nextLink'
             )
    }

    $items = $allPages
    "Count items: " + $items.Count

    $filePath = "D:\home\data\$($fileName)"

    Write-Host "Convert to csv to path '$($filePath)'" -ForegroundColor green
    $items | Export-Csv -NoTypeInformation -Path $filePath
powershell timer azure-functions timeout
1个回答
0
投票

我可以运行需要运行 1 小时以上的 Azure Functions 吗?

是的,您可以运行 Azure 函数超过一小时。

  • 消费计划中,默认时长为5分钟,最大时长为10分钟
  • 高级计划中,默认持续时间为30分钟。尽管最大持续时间在技术上是无限制的,但函数执行仅保证60分钟
  • 因此,您可以选择专用(应用程序服务)计划,该计划允许将超时时间增加一个小时以上

host.json中设置

functionTimeout
属性:

{
  "functionTimeout":"02:00:00"
}
  • 创建了一个 PowerShell Azure 函数并使用
    functionTimeout
    属性设置函数的超时。
{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    }
  },
  "managedDependency": {
    "enabled": true
  },
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[4.*, 5.0.0)"
  },
  "functionTimeout":"02:00:00"
}

回复:

enter image description here

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