MCPcopy Index your code
hub / github.com/Azure/powershell

github.com/Azure/powershell @v3.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v3.0.0 ↗ · + Follow
399 symbols 801 edges 17 files 79 documented · 20% 2 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

GitHub action for Azure PowerShell

This repository contains GitHub action for Azure PowerShell to automate your GitHub workflows using Azure PowerShell scripts.

Get started today with a free Azure account!

The definition of this GitHub Action is in action.yml.

[!NOTE] Azure PowerShell action now supports macOS and self-hosted Runners!

Dependencies on other GitHub Actions

Login to Azure before running Azure PowerShell scripts using Azure Login. Refer Azure Login action on how to configure Azure credentials.

Both Azure Login and Azure PowerShell action uses Az module.

Once login is done, Azure PowerShell action will use the same session to run the script.

Sample Workflow

Sample workflow to run inlineScript

on: [push]

name: AzurePowerShellSample

jobs:

  build:
    runs-on: ubuntu-latest
    steps:

    - name: Login via Az module
      uses: azure/login@v3
      with:
        creds: ${{secrets.AZURE_CREDENTIALS}}
        enable-AzPSSession: true 

    - name: Run Azure PowerShell inline script
      uses: azure/powershell@v3
      with:
        inlineScript: |
          Get-AzVM -ResourceGroupName "ResourceGroup11"
        azPSVersion: "latest"

Azure PowerShell Script to be executed can be given under inlineScript as shown in the sample workflow.

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 by setting appropriate value for the environment parameter.

Additionally the action supports two optional parameters:

  • errorActionPreference : select a suitable  value for the variable for executing the script. Allowed values are stop, continue, silentlyContinue. Default is Stop.
  • 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.

Sample workflow to run a script file in your repository

# File: ./scripts/run_azps_cmdlets.ps1
on: [push]

name: AzurePowerShellSampleWithFile

jobs:

  build:
    runs-on: ubuntu-latest
    steps:

    - name: Check Out
      uses: actions/checkout@v6

    - name: Login Azure
      uses: azure/login@v3
      with:
        creds: ${{secrets.AZURE_CREDENTIALS}}
        enable-AzPSSession: true 

    - name: Run Azure PowerShell Script File
      uses: azure/powershell@v3
      with:
        inlineScript: ./scripts/run_azps_cmdlets.ps1
        azPSVersion: "latest"

You have to check out the repository before running the script file. You can also run the script file with parameters. For example:

    - name: Run Azure PowerShell Script File
      uses: azure/powershell@v3
      with:
        inlineScript: ./scripts/run_azps_cmdlets.ps1 myresourcegroup myresourcename
        azPSVersion: "latest"

or

    - name: Run Azure PowerShell Script File
      uses: azure/powershell@v3
      with:
        inlineScript: ./scripts/run_azps_cmdlets.ps1 -ResourceGroupName myresourcegroup -ResourceName myresourcename
        azPSVersion: "latest"

Sample workflow to run Azure powershell actions in Azure US Government cloud

   - name: Login to Azure US Gov Cloud with Az Powershell 
        uses: azure/login@v3
        with:
          creds: ${{ secrets.AZURE_US_GOV_CREDENTIALS }}
          environment: 'AzureUSGovernment'
          enable-AzPSSession: true

      - name: Run powershell command in US Gov Cloud
        uses: azure/powershell@v3
        with:
          inlineScript: "Get-AzContext"
          azPSVersion: "latest"

Available versions of Az Module on runner

To use the latest Az module version, specify latest. You can find the latest Az module versions on different runner images from this table.

Or you can find all supported Az version on PowerShell Gallery.

Getting Help for Azure PowerShell Issues

If you encounter an issue related to the Azure PowerShell commands executed in your script, you can file an issue directly on the Azure PowerShell repository.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Extension points exported contracts — how you extend this code

InstallResult (Interface)
(no doc)
src/AzModuleInstaller.ts

Core symbols most depended-on inside this repo

step
called by 60
lib/index.js
_interopRequireDefault
called by 42
lib/index.js
tok
called by 38
lib/index.js
debug
called by 35
lib/index.js
toString
called by 34
lib/index.js
adopt
called by 20
lib/index.js
request
called by 19
lib/index.js
wrap
called by 16
lib/index.js

Shape

Function 174
Method 162
Class 62
Interface 1

Languages

TypeScript100%

Modules by API surface

lib/index.js343 symbols
src/Utilities/Utils.ts11 symbols
src/AzModuleInstaller.ts11 symbols
src/Utilities/FileUtils.ts6 symbols
src/Utilities/ArchiveTools.ts6 symbols
src/Utilities/ScriptBuilder.ts5 symbols
src/Utilities/PowerShellToolRunner.ts5 symbols
src/ScriptRunner.ts4 symbols
src/main.ts3 symbols
src/InitializeAzure.ts3 symbols
src/Constants.ts2 symbols

Used by 2 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add powershell \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact