Skip to content

Commit 1b0d1db

Browse files
committed
Address Acrolinx issues in file
- Reference 7.4 over 7.2 when possible
1 parent a59a0b6 commit 1b0d1db

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

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

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ ms.date: 04/22/2019
1313

1414
This article provides details about how you write Azure Functions using PowerShell.
1515

16-
A PowerShell Azure function (function) is represented as a PowerShell script that executes when triggered. Each function script has a related `function.json` file that defines how the function behaves, such as how it's triggered and its input and output parameters. To learn more, see the [Triggers and binding article](functions-triggers-bindings.md).
16+
A PowerShell Azure function (function) is represented as a PowerShell script that executes when triggered. Each function script has a related `function.json` file that defines how the function behaves, such as how it is triggered and its input and output parameters. To learn more, see the [Triggers and binding article](functions-triggers-bindings.md).
1717

1818
Like other kinds of functions, PowerShell script functions take in parameters that match the names of all the input bindings defined in the `function.json` file. A `TriggerMetadata` parameter is also passed that contains additional information on the trigger that started the function.
1919

20-
This article assumes that you have already read the [Azure Functions developer reference](functions-reference.md). You should have also completed the [Functions quickstart for PowerShell](./create-first-function-vs-code-powershell.md) to create your first PowerShell function.
20+
This article assumes that you have already read the [Azure Functions developer reference](functions-reference.md). It also assumes you have completed the [Functions quickstart for PowerShell](./create-first-function-vs-code-powershell.md) to create your first PowerShell function.
2121

2222
## Folder structure
2323

24-
The required folder structure for a PowerShell project looks like the following. This default can be changed. For more information, see the [scriptFile](#configure-function-scriptfile) section below.
24+
The required folder structure for a PowerShell project looks like the following. This default can be changed. For more information, see the [scriptFile](#configure-function-scriptfile) section.
2525

2626
```
2727
PSFunctionApp
@@ -48,15 +48,15 @@ PSFunctionApp
4848

4949
At the root of the project, there's a shared [`host.json`](functions-host-json.md) file that can be used to configure the function app. Each function has a folder with its own code file (.ps1) and binding configuration file (`function.json`). The name of the function.json file's parent directory is always the name of your function.
5050

51-
Certain bindings require the presence of an `extensions.csproj` file. Binding extensions, required in [version 2.x and later versions](functions-versions.md) of the Functions runtime, are defined in the `extensions.csproj` file, with the actual library files in the `bin` folder. When developing locally, you must [register binding extensions](functions-bindings-register.md#extension-bundles). When developing functions in the Azure portal, this registration is done for you.
51+
Certain bindings require the presence of an `extensions.csproj` file. Binding extensions, required in [version 2.x and later versions](functions-versions.md) of the Functions runtime, are defined in the `extensions.csproj` file, with the actual library files in the `bin` folder. When developing locally, you must [register binding extensions](functions-bindings-register.md#extension-bundles). When you are developing functions in the Azure portal, this registration is done for you.
5252

5353
In PowerShell Function Apps, you may optionally have a `profile.ps1` which runs when a function app starts to run (otherwise know as a *[cold start](#cold-start)*). For more information, see [PowerShell profile](#powershell-profile).
5454

5555
## Defining a PowerShell script as a function
5656

5757
By default, the Functions runtime looks for your function in `run.ps1`, where `run.ps1` shares the same parent directory as its corresponding `function.json`.
5858

59-
Your script is passed a number of arguments on execution. To handle these parameters, add a `param` block to the top of your script as in the following example:
59+
Your script is passed several arguments on execution. To handle these parameters, add a `param` block to the top of your script as in the following example:
6060

6161
```powershell
6262
# $TriggerMetadata is optional here. If you don't need it, you can safely remove it from the param block
@@ -65,7 +65,7 @@ param($MyFirstInputBinding, $MySecondInputBinding, $TriggerMetadata)
6565

6666
### TriggerMetadata parameter
6767

68-
The `TriggerMetadata` parameter is used to supply additional information about the trigger. The additional metadata varies from binding to binding but they all contain a `sys` property that contains the following data:
68+
The `TriggerMetadata` parameter is used to supply additional information about the trigger. This metadata varies from binding to binding but they all contain a `sys` property that contains the following data:
6969

7070
```powershell
7171
$TriggerMetadata.sys
@@ -81,7 +81,7 @@ Every trigger type has a different set of metadata. For example, the `$TriggerMe
8181

8282
## Bindings
8383

84-
In PowerShell, [bindings](functions-triggers-bindings.md) are configured and defined in a function's function.json. Functions interact with bindings a number of ways.
84+
In PowerShell, [bindings](functions-triggers-bindings.md) are configured and defined in a function's function.json. Functions interact with bindings in a number of ways.
8585

8686
### Reading trigger and input data
8787

@@ -95,7 +95,7 @@ param($MyFirstInputBinding, $MySecondInputBinding)
9595

9696
In Functions, an output binding has a `direction` set to `out` in the function.json. You can write to an output binding by using the `Push-OutputBinding` cmdlet, which is available to the Functions runtime. In all cases, the `name` property of the binding as defined in `function.json` corresponds to the `Name` parameter of the `Push-OutputBinding` cmdlet.
9797

98-
The following shows how to call `Push-OutputBinding` in your function script:
98+
The following example shows how to call `Push-OutputBinding` in your function script:
9999

100100
```powershell
101101
param($MyFirstInputBinding, $MySecondInputBinding)
@@ -113,7 +113,7 @@ Produce-MyOutputValue | Push-OutputBinding -Name myQueue
113113

114114
`Push-OutputBinding` behaves differently based on the value specified for `-Name`:
115115

116-
* When the specified name cannot be resolved to a valid output binding, then an error
116+
* When the specified name can't be resolved to a valid output binding, then an error
117117
is thrown.
118118

119119
* When the output binding accepts a collection of values, you can call `Push-OutputBinding` repeatedly to push multiple values.
@@ -269,7 +269,7 @@ If you're running your Function App locally for development, logs default to the
269269

270270
## Triggers and bindings types
271271

272-
There are a number of triggers and bindings available to you to use with your function app. The full list of triggers and bindings [can be found here](functions-triggers-bindings.md#supported-bindings).
272+
There are many triggers and bindings available to you to use with your function app. The full list of triggers and bindings [can be found here](functions-triggers-bindings.md#supported-bindings).
273273

274274
All triggers and bindings are represented in code as a few real data types:
275275

@@ -291,11 +291,11 @@ HTTP and webhook triggers and HTTP output bindings use request and response obje
291291

292292
#### Request object
293293

294-
The request object that's passed into the script is of the type `HttpRequestContext`, which has the following properties:
294+
The request object that is passed into the script is of the type `HttpRequestContext`, which has the following properties:
295295

296296
| Property | Description | Type |
297297
|-----------|----------------------------------------------------------------|---------------------------|
298-
| **`Body`** | An object that contains the body of the request. `Body` is serialized into the best type based on the data. For example, if the data is JSON, it's passed in as a hashtable. If the data is a string, it's passed in as a string. | object |
298+
| **`Body`** | An object that contains the body of the request. `Body` is serialized into the best type based on the data. For example, if the data is JSON, it is passed in as a hashtable. If the data is a string, it's passed in as a string. | object |
299299
| **`Headers`** | A dictionary that contains the request headers. | Dictionary<string,string><sup>*</sup> |
300300
| **`Method`** | The HTTP method of the request. | string |
301301
| **`Params`** | An object that contains the routing parameters of the request. | Dictionary<string,string><sup>*</sup> |
@@ -319,7 +319,7 @@ The response object that you should send back is of the type `HttpResponseContex
319319

320320
When you work with HTTP triggers, you can access the HTTP request the same way you would with any other input binding. It's in the `param` block.
321321

322-
Use an `HttpResponseContext` object to return a response, as shown in the following:
322+
Use an `HttpResponseContext` object to return a response, as shown in the following example:
323323

324324
`function.json`
325325

@@ -394,7 +394,7 @@ The following table shows the PowerShell versions available to each major versio
394394

395395
You can see the current version by printing `$PSVersionTable` from any function.
396396

397-
To learn more about Azure Functions runtime support policy, please refer to this [article](./language-support-policy.md)
397+
To learn more about Azure Functions runtime support policy, refer to this [article](./language-support-policy.md)
398398

399399
> [!NOTE]
400400
> Support for PowerShell 7.2 in Azure Functions ends on November 8, 2024. You might have to resolve some breaking changes when upgrading your PowerShell 7.2 functions to run on PowerShell 7.4. Follow this [migration guide](https://github.com/Azure/azure-functions-powershell-worker/wiki/Upgrading-your-Azure-Function-Apps-to-run-on-PowerShell-7.4) to upgrade to PowerShell 7.4.
@@ -424,7 +424,7 @@ Take these considerations into account before you migrate your PowerShell functi
424424

425425
+ Make sure that your function app is running on the latest version of the Functions runtime in Azure, which is version 4.x. For more information, see [View and update the current runtime version](set-runtime-version.md#view-the-current-runtime-version).
426426

427-
Use the following steps to change the PowerShell version used by your function app. You can do this either in the Azure portal or by using PowerShell.
427+
Use the following steps to change the PowerShell version used by your function app. You can perform this operation either in the Azure portal or by using PowerShell.
428428

429429
# [Portal](#tab/portal)
430430

@@ -448,7 +448,7 @@ Set-AzResource -ResourceId "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RES
448448
449449
```
450450

451-
Replace `<SUBSCRIPTION_ID>`, `<RESOURCE_GROUP>`, and `<FUNCTION_APP>` with the ID of your Azure subscription, the name of your resource group and function app, respectively. Also, replace `<VERSION>` with `7.4`. You can verify the updated value of the `powerShellVersion` setting in `Properties` of the returned hash table.
451+
Replace `<SUBSCRIPTION_ID>`, `<RESOURCE_GROUP>`, and `<FUNCTION_APP>` with the ID of your Azure subscription, the name of your resource group and function app, respectively. Also, replace `<VERSION>` with `7.4`. You can verify the updated value of the `powerShellVersion` setting in `Properties` of the returned hash table.
452452

453453
---
454454

@@ -466,20 +466,20 @@ Managing modules in Azure Functions written in PowerShell can be approached in t
466466

467467
**Why include modules in app content?**
468468
- **No dependency on the PowerShell Gallery**: Modules are bundled with your app, eliminating external dependencies.
469-
- **More control**: Avoids the risk of auto-upgrade regressions, giving you full control over which module versions are used.
469+
- **More control**: Avoids the risk of regressions caused by automatic upgrades, giving you full control over which module versions are used.
470470
- **Compatibility**: Works on Flex Consumption and is recommended for other Linux SKUs.
471471

472472
### Managed Dependencies feature
473473

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.
474+
The Managed Dependencies feature allows Azure Functions to automatically download and manage PowerShell modules specified in the `requirements.psd1` file. This feature is enabled by default in new PowerShell function apps.
475475

476476
#### Configuring requirements.psd1
477477

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.
478+
To use 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.
479479

480-
Here is how to set up and configure the `requirements.psd1` file:
480+
Here's how to set up and configure the `requirements.psd1` file:
481481

482-
1. Create a `requirements.psd1` file in the root directory of your Azure Function if one does not already exist.
482+
1. Create a `requirements.psd1` file in the root directory of your Azure Function if one doesn't already exist.
483483
2. Define the modules and their versions in a PowerShell data structure.
484484

485485
Example `requirements.psd1` file:
@@ -555,7 +555,7 @@ In order for Managed Dependencies to function, the feature must be enabled in ho
555555

556556
#### Target specific versions
557557

558-
When targeting specific module versions, it’s important to follow both steps below to ensure the correct module version is loaded:
558+
When targeting specific module versions, it’s important to follow both of the following steps to ensure the correct module version is loaded:
559559

560560
1. **Specify the module version in `requirements.psd1`:**
561561

@@ -571,7 +571,7 @@ When targeting specific module versions, it’s important to follow both steps b
571571
Import-Module Az.Accounts -RequiredVersion '1.9.5'
572572
```
573573
574-
This ensures the specified version is loaded when your function starts.
574+
Following these steps ensures the specified version is loaded when your function starts.
575575
576576
#### Configure specific Managed Dependency interval settings
577577
@@ -586,8 +586,8 @@ You can configure how Managed Dependencies are downloaded and installed using th
586586
#### Dependency management considerations
587587
588588
- **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.
589+
- **License Acceptance**: Managed Dependencies doesn't support modules that require license acceptance.
590+
- **Flex Consumption Plan**: The Managed Dependencies feature isn't supported in the Flex Consumption plan. Use custom modules instead.
591591
592592
## Concurrency
593593
@@ -598,9 +598,9 @@ By default, the Functions PowerShell runtime can only process one invocation of
598598
599599
There are a few concurrency models that you could explore depending on the type of workload:
600600
601-
* Increase ```FUNCTIONS_WORKER_PROCESS_COUNT```. This allows handling function invocations in multiple processes within the same instance, which introduces certain CPU and memory overhead. In general, I/O-bound functions will not suffer from this overhead. For CPU-bound functions, the impact may be significant.
601+
* Increase ```FUNCTIONS_WORKER_PROCESS_COUNT```. Increasing this setting allows handling function invocations in multiple processes within the same instance, which introduces certain CPU and memory overhead. In general, I/O-bound functions don't suffer from this overhead. For CPU-bound functions, the impact may be significant.
602602
603-
* Increase the ```PSWorkerInProcConcurrencyUpperBound``` app setting value. This allows creating multiple runspaces within the same process, which significantly reduces CPU and memory overhead.
603+
* Increase the ```PSWorkerInProcConcurrencyUpperBound``` app setting value. Increasing this setting allows creating multiple runspaces within the same process, which significantly reduces CPU and memory overhead.
604604
605605
You set these environment variables in the [app settings](functions-app-settings.md) of your function app.
606606
@@ -611,7 +611,7 @@ Depending on your use case, Durable Functions may significantly improve scalabil
611611
612612
### Considerations for using concurrency
613613
614-
PowerShell is a *single_threaded* scripting language by default. However, concurrency can be added by using multiple PowerShell runspaces in the same process. The number of runspaces created, and therefore the number of concurrent threads per worker, is limited by the `PSWorkerInProcConcurrencyUpperBound` application setting. By default, the number of runspaces is set to 1,000 in version 4.x of the Functions runtime. In versions 3.x and below, the maximum number of runspaces is set to 1. The throughput will be impacted by the amount of CPU and memory available in the selected plan.
614+
PowerShell is a *single_threaded* scripting language by default. However, concurrency can be added by using multiple PowerShell runspaces in the same process. The number of runspaces created, and therefore the number of concurrent threads per worker, is limited by the `PSWorkerInProcConcurrencyUpperBound` application setting. By default, the number of runspaces is set to 1,000 in version 4.x of the Functions runtime. In versions 3.x and below, the maximum number of runspaces is set to 1. The throughput of your function app is impacted by the amount of CPU and memory available in the selected plan.
615615
616616
Azure PowerShell uses some *process-level* contexts and state to help save you from excess typing. However, if you turn on concurrency in your function app and invoke actions that change state, you could end up with race conditions. These race conditions are difficult to debug because one invocation relies on a certain state and the other invocation changed the state.
617617
@@ -645,7 +645,7 @@ In this case, the `function.json` for `myFunction` includes a `scriptFile` prope
645645

646646
## Use PowerShell modules by configuring an entryPoint
647647

648-
This article has shown PowerShell functions in the default `run.ps1` script file generated by the templates.
648+
PowerShell functions in this article are shown with the default `run.ps1` script file generated by the templates.
649649
However, you can also include your functions in PowerShell modules. You can reference your specific function code in the module by using the `scriptFile` and `entryPoint` fields in the function.json` configuration file.
650650

651651
In this case, `entryPoint` is the name of a function or cmdlet in the PowerShell module referenced in `scriptFile`.
@@ -673,7 +673,7 @@ function Invoke-PSTestFunc {
673673
Export-ModuleMember -Function "Invoke-PSTestFunc"
674674
```
675675

676-
In this example, the configuration for `myFunction` includes a `scriptFile` property that references `PSFunction.psm1`, which is a PowerShell module in another folder. The `entryPoint` property references the `Invoke-PSTestFunc` function, which is the entry point in the module.
676+
In this example, the configuration for `myFunction` includes a `scriptFile` property that references `PSFunction.psm1`, which is a PowerShell module in another folder. The `entryPoint` property references the `Invoke-PSTestFunc` function, which is the entry point in the module.
677677

678678
```json
679679
{
@@ -699,7 +699,7 @@ When developing Azure Functions in the [serverless hosting model](consumption-pl
699699

700700
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.
701701

702-
For more information, refer to the [Module Management](#module-management) section.
702+
For more information, see the [Module Management](#module-management) section.
703703

704704
## Next steps
705705

0 commit comments

Comments
 (0)