I have an Azure function that is running PowerShell. I'm trying to write to an Azure database. Testing this locally is working but when I've moved into azure I'm having problems importing the AZ.SQL module that the code requires.
Things I've tried:
1: Enabling Managed Dependency but adding this to the Host.json file:
"managedDependency": {
"Enabled": true
}
The error I get from the above when I add into Visual Studio Code is "Property managedDependency is not allowed".
Documentation clearly states that by enabling this should allow, providing the requirements.psd1 file has the following entry in: ' 'Az ' = '6.*'' which I have too.
https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-powershell?tabs=portal#dependency-management.
2: Uploading the az.sql module into the module folder inside the Function app which should apparently do the same thing. This is also failing. I've been following this article - https://tech.nicolonsky.ch/azure-functions-powershell-modules/
I can't find any other information and have hit a wall.
The error I'm getting in my function app is this:
2021-08-15T15:19:23.156 [Information] INFORMATION: PowerShell HTTP trigger function processed a request.
2021-08-15T15:19:23.227 [Information] INFORMATION:
2021-08-15T15:19:26.713 [Warning] The Function app may be missing a module containing the 'Invoke-Sqlcmd' command definition. If this command belongs to a module available on the PowerShell Gallery, add a reference to this module to requirements.psd1. Make sure this module is compatible with PowerShell 7. For more details, see https://aka.ms/functions-powershell-managed-dependency. If the module is installed but you are still getting this error, try to import the module explicitly by invoking Import-Module just before the command that produces the error: this will not fix the issue but will expose the root cause.