question

koenverbeeck avatar image
0 Votes"
koenverbeeck asked koenverbeeck commented

Azure Function with PowerShell - could not load module (intermittently)

I'm using the module "dbatools" in an Azure Function using the PowerShell language.
Everything works fine locally. I deploy the Function to my Function App (consumption plan) and I can call the Azure Function successfully.
However, when I make parallel requests to the Function, some of them fail with the error "The 'Invoke-DbaQuery' command was found in the module 'dbatools', but the module could not be loaded."

199283-image.png

The weird thing is, some of the calls succeed, so apparently there's not always an issue loading the module. Here's a screenshot where some succeed, some fail (I'm calling the Function from Azure Data Factory):

199189-image.png

I tried using the module both as a managed dependency (so adding dbatools in the requirements.psd1 file), or as a custom module uploaded in the Modules folder. In both cases, the result is the same: some calls succeed, some fail.


windows-server-powershellazure-functions
image.png (31.0 KiB)
image.png (32.8 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I rewrote the Azure Function to do the same thing, but in C#. So I can move on with my work, but the original issue remains of course.

0 Votes 0 ·

1 Answer

LimitlessTechnology-2700 avatar image
0 Votes"
LimitlessTechnology-2700 answered koenverbeeck commented

Hi there,

This error occurs when "dbatools" is trying to call Azure Function, but Azure Function is getting failed.

Do you have any security software or endpoint protection running on your machine? If so try disabling them and see if you are getting the same response.

The below thread discusses the same issue and you can try out some troubleshooting steps from this and see if that helps you to sort the Issue. A user configuration issue with Error code 3600 https://docs.microsoft.com/en-us/answers/questions/817426/user-configuration-issue-with-error-code-3600.html

Here is a link that has some additional troubleshooting steps which you can try and see if helps in overcoming your issue. Azure Functions error handling and retries https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-error-pages?tabs=csharp



--If the reply is helpful, please Upvote and Accept it as an answer–

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

dbatools is the module the Azure Fuction is trying to load. The module itself doesn't call the Azure Function.

0 Votes 0 ·