1

I'm trying to use dependency feature (https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-powershell#dependency-management) but i can't get them working. I added few module (O365, ITGlue modules etc.). I tried to restart function app after changing requirements.psd1 but still nothing. I don't see any error in logs regarding dependencies. What I'm missing here?

See requirements.psd1 file

1 Answer 1

1

The first check would be to ensure that managedDependency property is set to true in your function's host.json file:

{
  "managedDependency": {
          "enabled": true
       }
}

Restart the app after updating the requirements.psd1 file with the modules you need. You can notice the updates being processed in the logs:

Logs

If you want to verify the installation, you can go to the Kudu site for your app, and navigate to the path D:\home\data\ManagedDependencies\<id>\ and find them listed:

Kudu

Another simple way of verifying the same would be to tweak the function to list it. For example:

using namespace System.Net

# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)

# Write to the Azure Functions log stream.
Write-Host "PowerShell HTTP trigger function processed a request."

# Interact with query parameters or the body of the request.
$name = $Request.Query.Name
if (-not $name) {
    $name = $Request.Body.Name
}

$body = "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."

if ($name) {
    $body = "Hello, $name. This HTTP triggered function executed successfully."
}

# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
    StatusCode = [HttpStatusCode]::OK
    # Body = $body
    Body = $(Get-Module -ListAvailable | Select-Object Name, Path)
})

Calling your function should now list all the installed dependencies: Example

Do note that Managed dependencies currently don't support modules that require the user to accept a license, either by accepting the license interactively, or by providing -AcceptLicense switch when invoking Install-Module. Also make sure that the runtime can access the PowerShell Gallery URL by adjusting any required firewall rules.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you Bhargavi for detailed answer. I was missing -usewindowspowershell when I imported modules as far as I can remember. (I asked this questions some time ago :) )
I have tried in same way its NOT able to download dependent libraries. I have verified in D:\home\data\ManagedDependencies\<id>\ also I have tried with {'Az' : '4.*'} and {'Az' : '5.*'}. In Kudu I am not able to see any Get-PackageSource and Get-PSRepository

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.