question

71824798 avatar image
0 Votes"
71824798 asked MayankBargali-MSFT commented

How to install modules with Functions

I would like to ask you about the title "How to install modules in Functions".

We are creating a VM stop function (language: PowerShell) in Functions.
The following error is displayed at the time of execution and the process is not executed.

The term'Disable-AzContextAutosave' is not recognized as the name of a cmdlet
The term'Connect-AzAccount' is not recognized as the name of a cmdlet
The term'Stop-AzVM' is not recognized as the name of a cmdlet


It seems that the following modules need to be installed as a countermeasure.
--Az.Compute
--Az.Accounts

How to install modules with Functions
Can you teach me?

that's all, thank you very much.

azure-functions
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.

1 Answer

MayankBargali-MSFT avatar image
0 Votes"
MayankBargali-MSFT answered MayankBargali-MSFT commented

@71824798 Please refer to Dependency management and Target specific versions for more details.
You need to enable managedDependency and update requirements.psd1 file.

· 2
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.

Thank you for your answer.

Does that mean I need to create host.json and requirements.psd1 and upload them inside the function?

Is the content at that time as follows?

[host.json]
{
"managedDependency": {
"enabled": true
}
}

[requirements.psd1]
@ {
Az = '1.
'
}*

0 Votes 0 ·

@71824798 Yes this should help. You can change the Az version to 6.0 or any version according to your requirement.

0 Votes 0 ·