You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-functions/functions-reference-powershell.md
+31-21Lines changed: 31 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -458,41 +458,41 @@ The function app restarts after the change is made to the configuration.
458
458
459
459
Managing modules in Azure Functions written in PowerShell can be approached in two ways: using the Managed Dependencies feature or including the modules directly in your app content. Each method has its own advantages, and choosing the right one depends on your specific needs.
460
460
461
-
### Choosing the Right Module Management Approach
461
+
### Choosing the right module management approach
462
462
463
-
**Managed Dependencies Feature**
463
+
**Why use the Managed Dependencies feature?**
464
464
-**Simplified initial installation**: Automatically handles module installation based on your `requirements.psd1` file.
465
465
-**Auto-upgrades**: Modules are updated automatically, including security fixes, without requiring manual intervention.
466
466
467
-
**Including Modules in App Content**
467
+
**Why include modules in app content?**
468
468
-**No dependency on the PowerShell Gallery**: Modules are bundled with your app, eliminating external dependencies.
469
469
-**More control**: Avoids the risk of auto-upgrade regressions, giving you full control over which module versions are used.
470
470
-**Compatibility**: Works on Flex Consumption and is recommended for other Linux SKUs.
471
471
472
-
### Managed Dependencies Feature
472
+
### Managed Dependencies feature
473
473
474
474
The Managed Dependencies feature allows Azure Functions to automatically download and manage PowerShell modules specified in the `requirements.psd1` file. This is enabled by default in new PowerShell function apps.
475
475
476
476
#### Configuring requirements.psd1
477
477
478
-
Content Here
478
+
To leverage Managed Dependencies in Azure Functions with PowerShell, you need to configure a `requirements.psd1` file. This file specifies the modules your function requires, and Azure Functions automatically downloads and updates these modules to ensure that your environment stays up-to-date.
479
479
480
-
#### Dependency Management App Settings
480
+
Here is how to set up and configure the `requirements.psd1` file:
481
481
482
-
You can configure how managed dependencies are downloaded and installed using the following app settings:
482
+
1. Create a `requirements.psd1` file in the root directory of your Azure Function if one does not already exist.
483
+
2. Define the modules and their versions in a PowerShell data structure.
|**MDMaxBackgroundUpgradePeriod**|`7.00:00:00` (seven days) | Controls the background update period for PowerShell function apps. |
487
-
|**MDNewSnapshotCheckPeriod**|`01:00:00` (one hour) | Specifies how often the PowerShell worker checks for updates. |
488
-
|**MDMinBackgroundUpgradePeriod**|`1.00:00:00` (one day) | Minimum time between upgrade checks. |
485
+
Example `requirements.psd1` file:
486
+
```powershell
487
+
@{
488
+
'Az' = '9.*' # Specifies the Az module and will use the latest version with major version 9
489
+
}
490
+
```
489
491
490
-
### Including Modules in App Content
492
+
### Including modules in app content
491
493
492
494
For more control over your module versions and to avoid dependencies on external resources, you can include modules directly in your function app’s content.
493
495
494
-
#### Function App-Level Modules Folder
495
-
496
496
To include custom modules:
497
497
498
498
1.**Create a `Modules` folder** at the root of your function app.
@@ -553,7 +553,7 @@ In order for Managed Dependencies to function, the feature must be enabled in ho
553
553
}
554
554
```
555
555
556
-
#### Target Specific Versions
556
+
#### Target specific versions
557
557
558
558
When targeting specific module versions, it’s important to follow both steps below to ensure the correct module version is loaded:
559
559
@@ -573,11 +573,21 @@ When targeting specific module versions, it’s important to follow both steps b
573
573
574
574
This ensures the specified version is loaded when your function starts.
575
575
576
-
#### Dependency Management Considerations
576
+
#### Configure specific Managed Dependency interval settings
577
+
578
+
You can configure how Managed Dependencies are downloaded and installed using the following app settings:
| **MDMaxBackgroundUpgradePeriod** | `7.00:00:00` (seven days) | Controls the background update period for PowerShell function apps. |
583
+
| **MDNewSnapshotCheckPeriod** | `01:00:00` (one hour) | Specifies how often the PowerShell worker checks for updates. |
584
+
| **MDMinBackgroundUpgradePeriod** | `1.00:00:00` (one day) | Minimum time between upgrade checks. |
585
+
586
+
#### Dependency management considerations
577
587
578
-
- **Internet Access**: Managed dependencies require access to `https://www.powershellgallery.com` to download modules. Ensure that your environment allows this access.
579
-
- **License Acceptance**: Modules that require license acceptance are not supported by managed dependencies.
580
-
- **Flex Consumption Plan**: Managed dependencies are not supported in the Flex Consumption plan. Use custom modules instead.
588
+
- **Internet Access**: Managed Dependencies require access to `https://www.powershellgallery.com` to download modules. Ensure that your environment allows this access, including modifying firewall/VNet rules as needed.
589
+
- **License Acceptance**: Modules that require license acceptance are not supported by Managed Dependencies.
590
+
- **Flex Consumption Plan**: Managed Dependencies are not supported in the Flex Consumption plan. Use custom modules instead.
581
591
582
592
## Concurrency
583
593
@@ -685,7 +695,7 @@ When you work with PowerShell functions, be aware of the considerations in the f
685
695
686
696
When developing Azure Functions in the [serverless hosting model](consumption-plan.md), cold starts are a reality. *Cold start* refers to period of time it takes for your function app to start running to process a request. Cold start happens more frequently in the Consumption plan because your function app gets shut down during periods of inactivity.
687
697
688
-
#### Avoid Using Install-Module
698
+
#### Avoid using Install-Module
689
699
690
700
Running `Install-Module` in your function script on each invocation can cause performance issues. Instead, use `Save-Module` or `Save-PSResource` before publishing your function app to bundle the necessary modules.
0 commit comments