Convert Figma logo to code with AI

Azure logoazure-powershell

Microsoft Azure PowerShell

4,207
3,806
4,207
1,400

Top Related Projects

PowerShell for every system!

Azure Command-Line Interface

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.

This repository is for active development of the Azure SDK for Java. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/java/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-java.

Quick Overview

Azure/azure-powershell is the official PowerShell module for managing Azure resources. It provides a comprehensive set of cmdlets for interacting with Azure services, allowing users to automate and manage their Azure infrastructure through PowerShell scripts and commands.

Pros

  • Extensive coverage of Azure services and resources
  • Regularly updated to support new Azure features and services
  • Integrates seamlessly with existing PowerShell workflows
  • Supports both Azure Cloud Shell and local PowerShell environments

Cons

  • Learning curve for users new to PowerShell or Azure
  • Some complex scenarios may require additional scripting or combining multiple cmdlets
  • Performance can be slower compared to using Azure CLI or REST APIs directly
  • Occasional breaking changes between major versions

Code Examples

  1. Logging in to Azure:
Connect-AzAccount
  1. Creating a new resource group:
New-AzResourceGroup -Name "MyResourceGroup" -Location "EastUS"
  1. Deploying a virtual machine:
New-AzVM -ResourceGroupName "MyResourceGroup" -Name "MyVM" -Location "EastUS" -VirtualNetworkName "MyVNet" -SubnetName "Default" -SecurityGroupName "MyNSG" -PublicIpAddressName "MyPublicIP"
  1. Listing all storage accounts in a subscription:
Get-AzStorageAccount | Select-Object ResourceGroupName, StorageAccountName, Location

Getting Started

  1. Install the Azure PowerShell module:
Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force
  1. Import the module:
Import-Module Az
  1. Log in to your Azure account:
Connect-AzAccount
  1. Set the subscription you want to work with:
Set-AzContext -SubscriptionId "your-subscription-id"

Now you're ready to start using Azure PowerShell cmdlets to manage your Azure resources.

Competitor Comparisons

PowerShell for every system!

Pros of PowerShell

  • Cross-platform support (Windows, macOS, Linux)
  • Open-source with a larger community and more frequent updates
  • Broader scope, covering general scripting and automation tasks

Cons of PowerShell

  • Steeper learning curve for beginners
  • Less focused on Azure-specific tasks and management
  • May require additional modules for Azure functionality

Code Comparison

PowerShell (general scripting):

$processes = Get-Process
foreach ($process in $processes) {
    Write-Output $process.Name
}

azure-powershell (Azure-specific):

$vms = Get-AzVM
foreach ($vm in $vms) {
    Write-Output $vm.Name
}

Summary

PowerShell is a versatile, cross-platform scripting language and shell, while azure-powershell is a specialized module for Azure management. PowerShell offers broader functionality and community support, but azure-powershell provides streamlined Azure-specific cmdlets. The choice between them depends on your specific needs: general scripting and automation (PowerShell) or focused Azure management (azure-powershell).

Azure Command-Line Interface

Pros of azure-cli

  • Cross-platform support (Windows, macOS, Linux)
  • More intuitive syntax for newcomers to Azure
  • Faster execution for certain operations

Cons of azure-cli

  • Less comprehensive coverage of Azure services
  • Limited scripting capabilities compared to PowerShell
  • Steeper learning curve for those already familiar with PowerShell

Code Comparison

azure-cli:

az vm create --resource-group myResourceGroup --name myVM --image UbuntuLTS --admin-username azureuser --generate-ssh-keys

azure-powershell:

New-AzVM -ResourceGroupName "myResourceGroup" -Name "myVM" -Image UbuntuLTS -Credential (Get-Credential)

Summary

azure-cli offers a more user-friendly approach for those new to Azure, with cross-platform support and simpler syntax. However, azure-powershell provides more comprehensive coverage of Azure services and better scripting capabilities, making it preferable for advanced users and automation tasks. The choice between the two depends on the user's familiarity with PowerShell, the specific Azure services required, and the need for cross-platform support.

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.

Pros of azure-sdk-for-python

  • Supports a wider range of programming paradigms and use cases in Python
  • More extensive and actively maintained documentation
  • Better integration with popular Python frameworks and tools

Cons of azure-sdk-for-python

  • Steeper learning curve for users not familiar with Python
  • May require additional setup and dependencies compared to PowerShell
  • Less native integration with Windows environments

Code Comparison

azure-powershell:

$resourceGroup = "myResourceGroup"
$vmName = "myVM"
$vm = Get-AzVM -ResourceGroupName $resourceGroup -Name $vmName
$vm.HardwareProfile.VmSize = "Standard_DS3_v2"
Update-AzVM -ResourceGroupName $resourceGroup -VM $vm

azure-sdk-for-python:

from azure.mgmt.compute import ComputeManagementClient

compute_client = ComputeManagementClient(credential, subscription_id)
vm = compute_client.virtual_machines.get(resource_group_name, vm_name)
vm.hardware_profile.vm_size = 'Standard_DS3_v2'
compute_client.virtual_machines.begin_update(resource_group_name, vm_name, vm)

Both repositories provide tools for managing Azure resources, but they cater to different ecosystems and user preferences. azure-powershell is more suitable for Windows administrators and those familiar with PowerShell, while azure-sdk-for-python offers greater flexibility and integration with Python-based applications and workflows.

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.

Pros of azure-sdk-for-net

  • Provides a more comprehensive set of Azure services and features
  • Offers better integration with .NET applications and frameworks
  • Supports asynchronous programming patterns

Cons of azure-sdk-for-net

  • Steeper learning curve for developers not familiar with .NET
  • May require more complex setup and configuration
  • Less suitable for quick scripting and automation tasks

Code Comparison

azure-powershell:

$resourceGroup = "myResourceGroup"
$vmName = "myVM"
$vm = Get-AzVM -ResourceGroupName $resourceGroup -Name $vmName
$vm.HardwareProfile.VmSize = "Standard_DS3_v2"
Update-AzVM -ResourceGroupName $resourceGroup -VM $vm

azure-sdk-for-net:

var resourceGroup = "myResourceGroup";
var vmName = "myVM";
var vm = await computeClient.VirtualMachines.GetAsync(resourceGroup, vmName);
vm.HardwareProfile.VmSize = VirtualMachineSizeTypes.StandardDS3V2;
await computeClient.VirtualMachines.CreateOrUpdateAsync(resourceGroup, vmName, vm);

Both repositories provide tools for managing Azure resources, but azure-sdk-for-net is more suitable for .NET developers building complex applications, while azure-powershell is better for quick scripting and automation tasks. The code comparison shows how azure-powershell uses cmdlets for resource management, while azure-sdk-for-net uses object-oriented programming and async/await patterns.

This repository is for active development of the Azure SDK for Java. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/java/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-java.

Pros of azure-sdk-for-java

  • Provides native Java support for Azure services
  • Offers object-oriented programming paradigm
  • Integrates seamlessly with Java ecosystems and build tools

Cons of azure-sdk-for-java

  • Steeper learning curve for non-Java developers
  • May require more verbose code compared to PowerShell cmdlets
  • Limited cross-platform compatibility compared to PowerShell

Code Comparison

azure-sdk-for-java:

BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
    .connectionString(connectionString)
    .buildClient();
BlobContainerClient containerClient = blobServiceClient.createBlobContainer("mycontainer");
BlobClient blobClient = containerClient.getBlobClient("myblob");
blobClient.upload(new ByteArrayInputStream(data), data.length);

azure-powershell:

$storageAccount = New-AzStorageAccount -ResourceGroupName "myResourceGroup" -Name "myStorageAccount" -Location "eastus" -SkuName "Standard_LRS"
$ctx = $storageAccount.Context
New-AzStorageContainer -Name "mycontainer" -Context $ctx
Set-AzStorageBlobContent -Container "mycontainer" -File "myblob" -Blob "myblob" -Context $ctx

Both repositories provide tools for interacting with Azure services, but they cater to different programming languages and paradigms. The choice between them depends on the developer's preferred language, existing codebase, and specific project requirements.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

AzureIcon PowershellIcon Microsoft Azure PowerShell

This repository contains PowerShell cmdlets for developers and administrators to develop, deploy, administer, and manage Microsoft Azure resources.

The Az PowerShell module is preinstalled in Azure Cloud Shell.

Modules

The following table contains a list of the Azure PowerShell rollup modules.

DescriptionModule NamePowerShell Gallery Link
Azure PowerShellAzAz
Azure PowerShell with preview modulesAzPreviewAzPreview

For a complete list of the modules found in this repository, see Azure PowerShell Modules.

Installation

PowerShell Gallery

Run the following command in a PowerShell session to install the Az PowerShell module:

Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force

The latest version of PowerShell 7 is the recommended version of PowerShell for use with the Az PowerShell module on all platforms including Windows, Linux, and macOS. This module also runs on Windows PowerShell 5.1 with .NET Framework 4.7.2 or higher.

The Az module replaces AzureRM. You should not install Az side-by-side with AzureRM.

If you have an earlier version of the Azure PowerShell module installed from the PowerShell Gallery and would like to update to the latest version, run the following command in a PowerShell session:

Update-Module -Name Az -Scope CurrentUser -Force

Update-Module installs the new version side-by-side with previous versions. It does not uninstall the previous versions.

For more information on installing Azure PowerShell, see the installation guide.

Usage

Log into Azure

To connect to Azure, use the Connect-AzAccount cmdlet:

# Opens a new browser window to log into your Azure account.
Connect-AzAccount

# Log in with a previously created service principal. Use the application ID as the username, and the secret as password.
$Credential = Get-Credential
Connect-AzAccount -ServicePrincipal -Credential $Credential -TenantId $TenantId

To log into a specific cloud (AzureChinaCloud, AzureCloud, AzureUSGovernment), use the Environment parameter:

# Log into a specific cloud, for example the Azure China cloud.
Connect-AzAccount -Environment AzureChinaCloud

Session context

A session context persists login information across Azure PowerShell modules and PowerShell instances. Use the Get-AzContext cmdlet to view the context you are using in the current session. The results contain the Azure tenant and subscription.

# Get the Azure PowerShell context for the current PowerShell session
Get-AzContext

# Lists all available Azure PowerShell contexts in the current PowerShell session
Get-AzContext -ListAvailable

To get the subscriptions in a tenant, use the Get-AzSubscription cmdlet:

# Get all of the Azure subscriptions in your current Azure tenant
Get-AzSubscription

# Get all of the Azure subscriptions in a specific Azure tenant
Get-AzSubscription -TenantId $TenantId

To change the subscription that you are using for your current context, use the Set-AzContext cmdlet:

# Set the Azure PowerShell context to a specific Azure subscription
Set-AzContext -Subscription $SubscriptionName -Name 'MyContext'

# Set the Azure PowerShell context using piping
Get-AzSubscription -SubscriptionName $SubscriptionName | Set-AzContext -Name 'MyContext'

For details on Azure PowerShell contexts, see Azure PowerShell context objects.

Discovering cmdlets

Use Get-Command to discover cmdlets within a specific module, or cmdlets that follow a specific search pattern:

# List all cmdlets in the Az.Accounts module
Get-Command -Module Az.Accounts

# List all cmdlets that contain VirtualNetwork in their name
Get-Command -Name '*VirtualNetwork*'

# List all cmdlets that contain VM in their name in the Az.Compute module
Get-Command -Module Az.Compute -Name '*VM*'

Cmdlet help and examples

To view the help content for a cmdlet, use the Get-Help cmdlet:

# View basic help information for Get-AzSubscription
Get-Help -Name Get-AzSubscription

# View the examples for Get-AzSubscription
Get-Help -Name Get-AzSubscription -Examples

# View the full help for Get-AzSubscription
Get-Help -Name Get-AzSubscription -Full

# View the online version of the help from https://learn.microsoft.com for Get-AzSubscription
Get-Help -Name Get-AzSubscription -Online

For detailed instructions on using Azure PowerShell, see the getting started guide.

Reporting Issues and Feedback

Issues

If you find any bugs when using Azure PowerShell, file an issue in our GitHub repo. Fill out the issue template with the appropriate information.

Alternatively, see Azure Community Support if you have issues with Azure PowerShell or Azure services.

Feedback

If there is a feature you would like to see in Azure PowerShell, use the Send-Feedback cmdlet, or file an issue in our GitHub repo.

Contributing

For details on contributing to this repository, see the contributing guide and the Azure PowerShell Developer Guide.

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.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., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories 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.

Telemetry

Azure PowerShell collects telemetry data by default. Microsoft aggregates collected data to identify patterns of usage to identify common issues and to improve the experience of Azure PowerShell. Microsoft Azure PowerShell does not collect any private or personal data. For example, the usage data helps identify issues such as cmdlets with low success and helps prioritize our work. While we appreciate the insights this data provides, we also understand that not everyone wants to send usage data. You can disable data collection with the Disable-AzDataCollection cmdlet. To learn more, see our privacy statement.

Learn More


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.