Skip to content

Commit f4601c0

Browse files
Merge pull request #303921 from mumian/0804-linter-ps
Add new linter rule for using recent AZ PowerShell
2 parents 48b6724 + 942335e commit f4601c0

8 files changed

+85
-13
lines changed

articles/azure-resource-manager/bicep/bicep-functions-files.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ resource exampleScript 'Microsoft.Resources/deploymentScripts@2023-08-01' = {
221221
}
222222
}
223223
properties: {
224-
azPowerShellVersion: '8.3'
224+
azPowerShellVersion: '14.0'
225225
scriptContent: loadTextContent('myscript.ps1')
226226
retentionInterval: 'P1D'
227227
}

articles/azure-resource-manager/bicep/deployment-script-bicep.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ resource deploymentScript 'Microsoft.Resources/deploymentScripts@2023-08-01' = {
110110
location: location
111111
kind: 'AzurePowerShell'
112112
properties: {
113-
azPowerShellVersion: '10.0'
113+
azPowerShellVersion: '14.0'
114114
arguments: '-name ${name}'
115115
scriptContent: '''
116116
param([string] $name)
@@ -253,7 +253,7 @@ resource deploymentScript 'Microsoft.Resources/deploymentScripts@2023-08-01' = {
253253
location: location
254254
kind: 'AzurePowerShell'
255255
properties: {
256-
azPowerShellVersion: '10.0'
256+
azPowerShellVersion: '14.0'
257257
arguments: '-name ${name}'
258258
scriptContent: '''
259259
param([string] $name)
@@ -374,7 +374,7 @@ SubscriptionId : aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e
374374
ProvisioningState : Succeeded
375375
Identity :
376376
ScriptKind : AzurePowerShell
377-
AzPowerShellVersion : 10.0
377+
AzPowerShellVersion : 14.0
378378
StartTime : 12/11/2023 9:45:50 PM
379379
EndTime : 12/11/2023 9:46:59 PM
380380
ExpirationDate : 12/11/2023 10:46:59 PM

articles/azure-resource-manager/bicep/deployment-script-develop.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Develop a deployment script in Bicep
33
description: Learn how to develop a deployment script within a Bicep file or store one externally as a separate file.
44
ms.custom: devx-track-bicep
55
ms.topic: conceptual
6-
ms.date: 07/25/2025
6+
ms.date: 08/06/2025
77
---
88

99
# Develop a deployment script in Bicep
@@ -121,10 +121,9 @@ In your deployment script, specify these property values:
121121

122122
See a list of [supported Azure PowerShell versions](https://mcr.microsoft.com/v2/azuredeploymentscripts-powershell/tags/list). The version determines which container image to use:
123123

124-
- Az version *greater than or equal to 9* uses Ubuntu 22.04.
125-
- Az version *greater than or equal to 6 but less than 9* uses Ubuntu 20.04.
126-
- Az version *less than 6* uses Ubuntu 18.04.
127-
124+
- Az version *greater than or equal to 12 uses Ubuntu 24.04.
125+
- Az version *greater than or equal to 9* but less than 12 uses Ubuntu 22.04.
126+
128127
> [!IMPORTANT]
129128
> We advise you to upgrade to the latest version of Ubuntu. Ubuntu 18.04 is nearing its end of support and won't receive security updates after [May 31, 2023](https://ubuntu.com/18-04).
130129

articles/azure-resource-manager/bicep/deployment-script-vnet-private-endpoint.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ resource privateDeploymentScript 'Microsoft.Resources/deploymentScripts@2023-08-
190190
}
191191
]
192192
}
193-
azPowerShellVersion: '9.0'
193+
azPowerShellVersion: '14.0'
194194
retentionInterval: 'P1D'
195195
scriptContent: 'Write-Host "Hello World!"'
196196
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
title: Linter rule - use recent AZ PowerShell version for deployment scripts
3+
description: Linter rule - use recent AZ PowerShell version for deployment scripts
4+
ms.topic: reference
5+
ms.custom: devx-track-bicep
6+
ms.date: 08/05/2025
7+
---
8+
9+
# Linter rule - use recent AZ PowerShell version for deployment scripts
10+
11+
This rule checks for AZ PowerShell versions below 11.0. It is recommended to use AZ PowerShell version 14.0.
12+
13+
## Linter rule code
14+
15+
Use the following value in the [Bicep configuration file](bicep-config-linter.md) to customize rule settings:
16+
17+
`use-recent-az-powershell-version`
18+
19+
## Solution
20+
21+
The following example doesn't pass this test because the `azPowerShellVersion` value is `10.4`:
22+
23+
```bicep
24+
param location string = resourceGroup().location
25+
26+
resource deploymentScript 'Microsoft.Resources/deploymentScripts@2023-08-01' = {
27+
name: 'inlinePS'
28+
location: location
29+
kind: 'AzurePowerShell'
30+
properties: {
31+
azPowerShellVersion: '10.4'
32+
scriptContent: '''
33+
$output = 'Hello world!'
34+
$DeploymentScriptOutputs = @{}
35+
$DeploymentScriptOutputs['text'] = $output
36+
'''
37+
retentionInterval: 'PT1H'
38+
}
39+
}
40+
41+
output result string = deploymentScript.properties.outputs.text
42+
```
43+
44+
Fix the problem by using version 11.0 or later:
45+
46+
```bicep
47+
param location string = resourceGroup().location
48+
49+
resource deploymentScript 'Microsoft.Resources/deploymentScripts@2023-08-01' = {
50+
name: 'inlinePS'
51+
location: location
52+
kind: 'AzurePowerShell'
53+
properties: {
54+
azPowerShellVersion: '14.0'
55+
scriptContent: '''
56+
$output = 'Hello world!'
57+
$DeploymentScriptOutputs = @{}
58+
$DeploymentScriptOutputs['text'] = $output
59+
'''
60+
retentionInterval: 'PT1H'
61+
}
62+
}
63+
64+
output result string = deploymentScript.properties.outputs.text
65+
```
66+
67+
## Next steps
68+
69+
Learn more in [Use Bicep linter](./linter.md).

articles/azure-resource-manager/bicep/linter.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ The default set of linter rules is minimal and taken from [arm-ttk test cases](.
5151
| <a id='simplify-json-null' />[simplify-json-null](./linter-rule-simplify-json-null.md) | warning |
5252
| <a id='use-parent-property' />[use-parent-property](./linter-rule-use-parent-property.md) | warning |
5353
| <a id='use-recent-api-versions' />[use-recent-api-versions](./linter-rule-use-recent-api-versions.md) | off |
54+
| <a id='use-recent-az-powershell-version' />[use-recent-az-powershell-version](./linter-rule-use-recent-az-powershell-version.md) | warning |
5455
| <a id='use-recent-module-versions' />[use-recent-module-versions](./linter-rule-use-recent-module-versions.md) | off |
5556
| <a id='use-resource-id-functions' />[use-resource-id-functions](./linter-rule-use-resource-id-functions.md) | off |
5657
| <a id='use-resource-symbol-reference' />[use-resource-symbol-reference](./linter-rule-use-resource-symbol-reference.md) | warning |

articles/azure-resource-manager/bicep/toc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,9 @@ items:
549549
- name: Use recent API versions
550550
displayName: linter
551551
href: linter-rule-use-recent-api-versions.md
552+
- name: Use recent AZ PowerShell version
553+
displayName: linter
554+
href: linter-rule-use-recent-az-powershell-version.md
552555
- name: Use recent module versions
553556
displayName: linter
554557
href: linter-rule-use-recent-module-versions.md

articles/azure-resource-manager/templates/deployment-script-template.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ The following JSON is an example. For more information, see the latest [template
113113
"storageAccountName": "myStorageAccount",
114114
"storageAccountKey": "myKey"
115115
},
116-
"azPowerShellVersion": "9.7", // or "azCliVersion": "2.47.0",
116+
"azPowerShellVersion": "14.0", // or "azCliVersion": "2.47.0",
117117
"arguments": "-name \\\"John Dole\\\"",
118118
"environmentVariables": [
119119
{
@@ -402,7 +402,7 @@ SubscriptionId : aaaabbbb-0000-cccc-1111-dddd2222eeee
402402
ProvisioningState : Succeeded
403403
Identity : /subscriptions/aaaabbbb-0000-cccc-1111-dddd2222eeee/resourceGroups/mydentity1008rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myuami
404404
ScriptKind : AzurePowerShell
405-
AzPowerShellVersion : 9.7
405+
AzPowerShellVersion : 14.0
406406
StartTime : 5/11/2023 7:46:45 PM
407407
EndTime : 5/11/2023 7:49:45 PM
408408
ExpirationDate : 5/12/2023 7:49:45 PM
@@ -541,7 +541,7 @@ The output is similar to:
541541
"properties": {
542542
"provisioningState": "Succeeded",
543543
"forceUpdateTag": "20220625T025902Z",
544-
"azPowerShellVersion": "9.7",
544+
"azPowerShellVersion": "14.0",
545545
"scriptContent": "\r\n param([string] $name)\r\n $output = \"Hello {0}\" -f $name\r\n Write-Output $output\r\n $DeploymentScriptOutputs = @{}\r\n $DeploymentScriptOutputs['text'] = $output\r\n ",
546546
"arguments": "-name \\\"John Dole\\\"",
547547
"retentionInterval": "P1D",

0 commit comments

Comments
 (0)