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: README.md
+31-23Lines changed: 31 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,26 @@
1
1
# GitHub action for Azure PowerShell
2
+
2
3
This repository contains GitHub action for Azure PowerShell to automate your GitHub workflows using Azure PowerShell scripts.
3
4
4
5
Get started today with a [free Azure account](https://azure.com/free/open-source)!
5
6
6
7
The definition of this GitHub Action is in [action.yml](https://github.com/azure/powershell/blob/master/action.yml).
7
8
8
-
## End-to-End Sample Workflow
9
+
> [!NOTE]
10
+
> Azure PowerShell action now supports macOS and self-hosted Runners!
9
11
10
-
###Dependencies on other GitHub Actions
12
+
## Dependencies on other GitHub Actions
11
13
12
14
Login to Azure before running Azure PowerShell scripts using [Azure Login](https://github.com/Azure/login). Refer [Azure Login](https://github.com/Azure/login#configure-azure-credentials) action on how to configure Azure credentials.
13
15
14
-
Once login is done, Azure PowerShell action will use the same session to run the script.
16
+
Both [Azure Login](https://github.com/Azure/login) and [Azure PowerShell](https://github.com/azure/powershell) action uses `Az` module.
17
+
18
+
Once login is done, Azure PowerShell action will use the same session to run the script.
19
+
20
+
## Sample Workflow
21
+
22
+
### Sample workflow to run inlineScript
15
23
16
-
#### Sample workflow to run inlinescript
17
24
```yaml
18
25
on: [push]
19
26
@@ -31,26 +38,25 @@ jobs:
31
38
creds: ${{secrets.AZURE_CREDENTIALS}}
32
39
enable-AzPSSession: true
33
40
34
-
- name: Run Azure PowerShell script
41
+
- name: Run Azure PowerShell inline script
35
42
uses: azure/powershell@v1
36
43
with:
37
44
inlineScript: |
38
45
Get-AzVM -ResourceGroupName "ResourceGroup11"
39
46
azPSVersion: "latest"
40
47
```
41
-
Azure PowerShell Script to be executed can be given under inlineScript as shown in the sample workflow.
42
48
43
-
Both [Azure Login](https://github.com/Azure/login) and [Azure PowerShell](https://github.com/azure/powershell) action uses Az module.
49
+
Azure PowerShell Script to be executed can be given under inlineScript as shown in the sample workflow.
44
50
45
-
Currently, Azure PowerShell action only supports ubuntu and windows runners. MacOS is not supported. Self hosted runners are not supported.
51
+
Azure PowerShell action is now supported for the Azure public cloud as well as Azure government clouds (`AzureUSGovernment` or `AzureChinaCloud`) and Azure Stack (`AzureStack`) Hub. Before running Azure PowerShell scripts, login to the respective Azure Cloud using [Azure Login action](https://github.com/Azure/login) by setting appropriate value for the `environment` parameter.
46
52
47
-
Azure PowerShell action is now supported for the Azure public cloud as well as Azure government clouds ('AzureUSGovernment' or 'AzureChinaCloud') and Azure Stack ('AzureStack') Hub. Before running Azure PowerShell scripts, login to the respective Azure Cloud using [Azure Login](https://github.com/Azure/login) by setting appropriate value for the `environment` parameter.
53
+
Additionally the action supports two optional parameters:
48
54
49
-
Additionally the action supports two optional parameters
50
55
- `errorActionPreference` : select a suitable value for the variable for executing the script. Allowed values are `stop`, `continue`, `silentlyContinue`. Default is `Stop`.
51
56
- `failOnStandardError` : By default this is marked as `false`. But if this is marked as `true`, the action will fail if any errors are written to the error pipeline, or if any data is written to the Standard Error stream.
52
57
53
-
#### Sample workflow to run a script file in your repository
58
+
### Sample workflow to run a script file in your repository
59
+
54
60
```yaml
55
61
# File: ./scripts/run_azps_cmdlets.ps1
56
62
on: [push]
@@ -78,16 +84,20 @@ jobs:
78
84
inlineScript: ./scripts/run_azps_cmdlets.ps1
79
85
azPSVersion: "latest"
80
86
```
87
+
81
88
You have to check out the repository before running the script file.
82
89
You can also run the script file with parameters. For example:
### Sample workflow to run Azure powershell actions in Azure US Government cloud
100
110
101
-
```
102
-
.......
103
-
.......
104
-
.......
105
-
111
+
```yaml
106
112
- name: Login to Azure US Gov Cloud with Az Powershell
107
-
uses: azure/login@releases/azcloud-v1
113
+
uses: azure/login@v1
108
114
with:
109
115
creds: ${{ secrets.AZURE_US_GOV_CREDENTIALS }}
110
116
environment: 'AzureUSGovernment'
@@ -117,20 +123,22 @@ or
117
123
azPSVersion: "latest"
118
124
```
119
125
120
-
#### Available versions of Az Module on runner
126
+
## Available versions of Az Module on runner
127
+
128
+
To use the latest Az module version, specify `latest`. You can find the latest Az module versions on different runner images from this [table](https://github.com/actions/runner-images#available-images).
121
129
122
-
To use the latest Az module version, specify 'latest'. You can find the latest Az module versions on different runner images from this [table](https://github.com/actions/runner-images#available-images).
130
+
Or you can find all supported `Az` version on [PowerShell Gallery](https://www.powershellgallery.com/packages/Az).
123
131
124
-
# Getting Help for Azure PowerShell Issues
132
+
## Getting Help for Azure PowerShell Issues
125
133
126
-
If you encounter an issue related to the Azure PowerShell commands executed in your script, you can
134
+
If you encounter an issue related to the Azure PowerShell commands executed in your script, you can
127
135
file an issue directly on the [Azure PowerShell repository](https://github.com/Azure/azure-powershell/issues/new/choose).
128
136
129
-
# Contributing
137
+
## Contributing
130
138
131
139
This project welcomes contributions and suggestions. Most contributions require you to agree to a
132
140
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
133
-
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
141
+
the rights to use your contribution. For details, visit <https://cla.opensource.microsoft.com>.
134
142
135
143
When you submit a pull request, a CLA bot will automatically determine whether you need to provide
136
144
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
0 commit comments