Can I run an scheduled ps Azure Function which needs to run more as 1 hour? I already try consumption and premium plan, but the scheduled Azure function stuck because of a timeout.
Update
I try to get all the group members in AAD. I run this ms graph url:
https://graph.microsoft.com/v1.0/groups?$top=999&$expand=members
But because there are more as 999 groupmembers I need to use the paging functionality. See code snippet below:
$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
Can I run an Azure Function which needs to run more as 1 hour?
yes, you can run the Azure functions more than one hour.
Set the functionTimeout attribute in host.json
:
{
"functionTimeout":"02:00:00"
}
functionTimeout
attribute to set the timeout of the function.{
"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"
}
Response: