0
votes

I've a Powershell script (below) that extracts a list of 'AccountEnabled' Azure Active Directory (AAD) users (approx. 35k users and 13MB in file size) which runs fine on my local machine although it takes a while (approx. 10 minutes)

However, when I deploy the code to Azure Function App using Durable Functions (tried both Consumption & Premium EP1 Plan) and do a test run, it authenticates successfully but from the log, it keeps repeating "no traces within the x minutes". When I inspect the blob storage location where the file is meant to be exported to, the file size is initially around 1.4MB but after a few minutes it seems to get replaced with a file of 700kB size and then 0kB size which is weird. Left it running for hours and nothing happened.

I then modified the script to only list users where their UserPrincipalName starts with the letter 'a' and it ran fine on Azure Functions; i.e: exported approx. 3k users in about 2 minutes and the Azure Function log shows it ran successfully too.

I'm kinda new to Azure Function and not sure where's the bottleneck/issue so it will be much appreciated if someone can please shed some light on it. Thanks in advance.

Get-AzureADUser -All $true -Filter 'AccountEnabled eq true' | Select-Object DeletionTimestamp,ObjectId,
ObjectType,AccountEnabled,AgeGroup,City,CompanyName,Country,CreationType,Department,DirSyncEnabled,
DisplayName,FacsimileTelephoneNumber,GivenName,IsCompromised,JobTitle,LastDirSyncTime,LegalAgeGroupClassification,
Mail,MailNickName,Mobile,OtherMails,PhysicalDeliveryOfficeName,PostalCode,PreferredLanguage,
RefreshTokensValidFromDateTime,ShowInAddressList,SignInNames,State,StreetAddress,Surname,TelephoneNumber,
UsageLocation,UserPrincipalName,UserState,UserStateChangedOn,UserType,
@{name='Licensed';expression={if($_.AssignedLicenses){$TRUE}else{$False}}},
@{name='Plan';expression={if($_.AssignedPlans){$TRUE}else{$False}}}, 
@{N="EmployeeId";E={$_.ExtensionProperty["employeeId"]} },
@{N="CreatedDateTime";E={$_.ExtensionProperty["createdDateTime"]} }
| Export-csv $FilePath -NoTypeInformation #stores results in a csv
1

1 Answers

0
votes

Most likely, your function times out. Have you tried to configure functionTimeout?

If your code requires more than 60 minutes on Premium or more than 10 minutes on Consumption, and you can split processing into smaller parts (e.g. by the first letter), consider using Durable Functions: you can use either Function chaining or Fan out/fan in pattern. The timeout will be applied to each activity invocation individually, but the entire orchestration execution time is unlimited.