Skip to content

Commit 9a45195

Browse files
authored
Merge pull request #92036 from ggailey777/patch-9
Edits for new Dependency management section
2 parents 92c86f6 + 97900da commit 9a45195

File tree

1 file changed

+21
-26
lines changed

1 file changed

+21
-26
lines changed

articles/azure-functions/functions-reference-powershell.md

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
---
22
title: PowerShell developer reference for Azure Functions
33
description: Understand how to develop functions by using PowerShell.
4-
services: functions
5-
documentationcenter: na
6-
author: tylerleonhardt
7-
manager: jeconnoc
4+
author: eamonoreilly
5+
manager: gwallace
86
ms.service: azure-functions
97
ms.devlang: powershell
108
ms.topic: conceptual
119
ms.date: 04/22/2019
12-
ms.author: tyleonha
13-
ms.reviewer: glenga
10+
ms.author: glenga
11+
1412
# Customer intent: As a PowerShell developer, I want to understand Azure Functions so that I can leverage the full power of the platform.
1513
---
1614

@@ -402,13 +400,8 @@ You can see the current version by printing `$PSVersionTable` from any function.
402400

403401
## Dependency management
404402

405-
PowerShell functions support downloading and managing [PowerShell gallery](https://www.powershellgallery.com) modules by the service. By modifying the host.json and setting the managedDependency enabled property to true, the requirements.psd1 file will be processed. The specified modules will be automatically downloaded and made available to the function.
406-
407-
The maximum number of modules currently supported is 10. The supported syntax is MajorNumber.* or exact module version as shown below. The Azure Az module is included by default when a new PowerShell function app is created.
403+
Functions lets you leverage [PowerShell gallery](https://www.powershellgallery.com) 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](functions-host-json.md), as in the following example:
408404

409-
The language worker will pick up any updated modules on a restart.
410-
411-
host.json
412405
```json
413406
{
414407
"managedDependency": {
@@ -417,7 +410,7 @@ host.json
417410
}
418411
```
419412

420-
requirements.psd1
413+
When you create a new PowerShell functions project, dependency management is enabled by default, with the Azure [`Az` module](/powershell/azure/new-azureps-module-az) included. The maximum number of modules currently supported is 10. The supported syntax is _`MajorNumber`_`.*` or exact module version as shown in the following requirements.psd1 example:
421414

422415
```powershell
423416
@{
@@ -426,32 +419,34 @@ requirements.psd1
426419
}
427420
```
428421

429-
The following settings are available to change how the managed dependencies are downloaded and installed. Your app upgrade will start within MDMaxBackgroundUpgradePeriod, and the upgrade process will complete within approximately MDNewSnapshotCheckPeriod.
422+
When you update the requirements.psd1 file, updated modules are installed after a restart.
423+
424+
> [!NOTE]
425+
> Managed dependencies requires access to www.powershellgallery.com to download modules. When running locally, make sure that the runtime can access this URL by adding any required firewall rules.
426+
427+
The following application settings can be used to change how the managed dependencies are downloaded and installed. Your app upgrade starts within `MDMaxBackgroundUpgradePeriod`, and the upgrade process completes within approximately the `MDNewSnapshotCheckPeriod`.
430428

431429
| Function App setting | Default value | Description |
432430
| ----------------------------- | ------------------- | ----------------------------------------------- |
433-
| MDMaxBackgroundUpgradePeriod | “7.00:00:00” (7 days) | Every PS Worker initiates checking for module upgrades on the PS Gallery on Worker process start and every MDMaxBackgroundUpgradePeriod after that. If new module versions are available on the PS Gallery, they will be installed to the file system available to PS Workers. Decreasing this value will let your Function app get newer module versions sooner, but will also increase the app resource usage (network I/O, CPU, storage). Increasing this value will decrease the app resource usage but may also delay delivering new module versions to your app. |
434-
| MDNewSnapshotCheckPeriod | “01:00:00” (1 hour) | After the new module versions are installed to the file system, every PS Worker needs to be restarted. Restarting PS Workers may affect your app availability because it may interrupt current function invocations. Until all PS Workers are restarted, function invocations may use either the old or the new module versions. Restarting all PS Workers will complete within MDNewSnapshotCheckPeriod. Increasing this value will decrease the frequency of interruptions, but may also increase the period of time when function invocations use either the old or the new module versions non-deterministically. |
435-
| MDMinBackgroundUpgradePeriod | “1.00:00:00” (1 day) | In order to avoid excessive module upgrades on frequent Worker restarts, checking for module upgrades will not be performed if any worker already initiated that within the last MDMinBackgroundUpgradePeriod. |
436-
437-
> [!NOTE]
438-
> Managed dependencies relies on access to www.powershellgallery.com to download modules. You need to ensure the function runtime has access to this url by adding any required firewall rules.
431+
| **`MDMaxBackgroundUpgradePeriod`** | `7.00:00:00` (7 days) | Each PowerShell worker process initiates checking for module upgrades on the PowerShell Gallery on process start and every `MDMaxBackgroundUpgradePeriod` after that. When a new module version is available in the PowerShell Gallery, it's installed to the file system and made available to PowerShell workers. Decreasing this value lets your function app get newer module versions sooner, but it also increases the app resource usage (network I/O, CPU, storage). Increasing this value decreases the app's resource usage, but it may also delay delivering new module versions to your app. |
432+
| **`MDNewSnapshotCheckPeriod`** | `01:00:00` (1 hour) | After new module versions are installed to the file system, every PowerShell worker process must be restarted. Restarting PowerShell workers affects your app availability as it can interrupt current function execution. Until all PowerShell worker processes are restarted, function invocations may use either the old or the new module versions. Restarting all PowerShell workers complete within `MDNewSnapshotCheckPeriod`. Increasing this value decreases the frequency of interruptions, but may also increase the period of time when function invocations use either the old or the new module versions non-deterministically. |
433+
| **`MDMinBackgroundUpgradePeriod`** | `1.00:00:00` (1 day) | To avoid excessive module upgrades on frequent Worker restarts, checking for module upgrades isn't performed when any worker has already initiated that check in the last `MDMinBackgroundUpgradePeriod`. |
439434

440435
Leveraging your own custom modules is a little different than how you would do it normally.
441436

442-
When you install the module on your local machine, it goes in one of the globally available folders in your `$env:PSModulePath`. Since your function runs in Azure, you won't have access to the modules installed on your machine. This requires that the `$env:PSModulePath` for a PowerShell function app differs from `$env:PSModulePath` in a regular PowerShell script.
437+
On your local computer, the module gets installed in one of the globally available folders in your `$env:PSModulePath`. When running in Azure, you don't have access to the modules installed on your machine. This means that the `$env:PSModulePath` for a PowerShell function app differs from `$env:PSModulePath` in a regular PowerShell script.
443438

444439
In Functions, `PSModulePath` contains two paths:
445440

446-
* A `Modules` folder that exists at the root of your Function App.
447-
* A path to a `Modules` folder that lives inside the PowerShell language worker.
441+
* A `Modules` folder that exists at the root of your function app.
442+
* A path to a `Modules` folder that is controlled by the PowerShell language worker.
448443

449444
### Function app-level `Modules` folder
450445

451446
To use custom modules, you can place modules on which your functions depend in a `Modules` folder. From this folder, modules are automatically available to the functions runtime. Any function in the function app can use these modules.
452447

453448
> [!NOTE]
454-
> Modules specified in the requirements.psd1 file are automatically downloaded and included in the path so you don't need to include them in the modules folder. These are stored locally in the $env:LOCALAPPDATA/AzureFunctions folder and in the /data/ManagedDependencies folder when run in the cloud.
449+
> Modules specified in the requirements.psd1 file are automatically downloaded and included in the path so you don't need to include them in the modules folder. These are stored locally in the `$env:LOCALAPPDATA/AzureFunctions` folder and in the `/data/ManagedDependencies` folder when run in the cloud.
455450
456451
To take advantage of the custom module feature, create a `Modules` folder in the root of your function app. Copy the modules you want to use in your functions to this location.
457452

@@ -460,7 +455,7 @@ mkdir ./Modules
460455
Copy-Item -Path /mymodules/mycustommodule -Destination ./Modules -Recurse
461456
```
462457

463-
With a Modules folder, your function app should have the following folder structure:
458+
With a `Modules` folder, your function app should have the following folder structure:
464459

465460
```
466461
PSFunctionApp
@@ -487,7 +482,7 @@ The current list of modules is as follows:
487482
* [Microsoft.PowerShell.Archive](https://www.powershellgallery.com/packages/Microsoft.PowerShell.Archive): module used for working with archives, like `.zip`, `.nupkg`, and others.
488483
* **ThreadJob**: A thread-based implementation of the PowerShell job APIs.
489484

490-
The most recent version of these modules is used by Functions. To use a specific version of these modules, you can put the specific version in the `Modules` folder of your function app.
485+
By default, Functions uses the most recent version of these modules. To use a specific module version, put that specific version in the `Modules` folder of your function app.
491486

492487
## Environment variables
493488

0 commit comments

Comments
 (0)