@Tati, Vinod Welcome to Microsoft Q&A Forum, Thank you for posting your query here!
I understand you are encountering an error while trying to use the Set-AzStorageAccount
command in their Function app. The error message suggests that a module containing the command definition is missing, and you should add a reference to this module in the requirements.psd1
file.
Plan 1:
Please ensure that you are using the below version for Function and powershell:**
**
Plan 2:
If you are using an older version of Powershell, you need to upgrade it to Powershell 7.2 by following this article:
https://github.com/Azure/azure-functions-powershell-worker/wiki/Upgrading-your-Azure-Function-Apps-to-run-on-PowerShell-7.2
Plan 3:
Please hard code the specific versions and test:
@{
'Az.Storage' = '5.10.0'
'Az.Accounts' = '2.13.0'
}
Plan 4:
I also recommended that you don't import all of the Az
module. So please remove 'Az' = '10.*'
as it will increase performance on cold starts. I feel there might be an issue with the dependencies causing the module to not load.
**
Plan 5:**
Functions lets you leverage PowerShell gallery for managing dependencies. With dependency management enabled, the requirements.psd1 file is used to automatically download required modules. You enable this behavior by setting the managedDependency
property to true
in the root of the host.json file, as in the following example:
{
"managedDependency": {
"enabled": true
}
}
After following the above plan , please restart the function app and test again.
If this doesn't help. Please let me know. I would be happy to assist you further.
**
Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.