Questions tagged [azure-powershell]

The Azure module for PowerShell allows administrators to accomplish management tasks for Azure resources. The Az wrapper module includes only stable modules, the AzPreview wrapper module includes all PowerShell modules for Azure allowing to manage resources in all Azure services.

The Azure Modules for PowerShell allows administrators to accomplish many Azure management tasks through a series of cmdlets. The modules include the new Az module and the older AzureRM module (due to retire by Feb 2024).

References:

  1. Overview of Azure PowerShell

  2. PowerShell Module Browser: Search for PowerShell modules and cmdlets.

2843 questions
7
votes
6 answers

How to prevent error "WARNING: Unable to acquire token for tenant 'tenantid'" when running Powershell scripts in Azure

I'm creating a Service principal to be used as an Azure Runas Account for Azure Automation, using a Powershell script. The script works, however I get the following warning when it's completed WARNING: Unable to acquire token for tenant 'tenantID'.…
Wayno
  • 351
  • 2
  • 3
  • 10
7
votes
1 answer

New-AzureADPolicy missed in the Azure cloud shell

New-AzureADPolicy missed in the Azure cloud shell New-AzureADPolicy : The term 'New-AzureADPolicy' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included,…
7
votes
1 answer

(Azure) az batch pool : error: 'NoneType' object has no attribute 'startswith'

Unable to create batch pool: > az login > az account set --subscription $myid > az batch account set --resource-group $resourceGroupName --name $batchAccountName > az batch pool create --json-file pool.json usage: az batch pool create [-h]…
zcahfg2
  • 861
  • 1
  • 12
  • 27
7
votes
4 answers

Azure Export SQL database example

Given Microsoft is deprecating the previous method of exporting a SQL DB they have put up a suggested example here: $subscriptionId = "YOUR AZURE SUBSCRIPTION ID" Login-AzureRmAccount Set-AzureRmContext -SubscriptionId $subscriptionId # Database…
7
votes
2 answers

List directories in a container

How can I get a list of directories in my container? I can use Get-AzureStorageBlob to get all the blobs and filter by distinct prefix /name/, but it might be slow with millions of blobs. Is there a proper way of achieving this in PowerShell?
Stefano d'Antonio
  • 5,874
  • 3
  • 32
  • 45
7
votes
3 answers

How to break a lease on Blob Storage in Azure with PowerShell?

How do I break a lease on an item in Blob Storage utilizing PowerShell? I'm receiving the following when trying to upload something over the current image: Add-AzureRmVhd : The remote server returned an error: (412) There is currently a lease on the…
Doug
  • 6,446
  • 9
  • 74
  • 107
7
votes
4 answers

List existing SASTokens on a container using Azure powershell

When creating a SASToken via powershell it retunrs the created SAS token url from New-AzureStorageContainerSASToken comdlet. $Context = New-AzureStorageContext -StorageAccountName $StorageAccount -StorageAccountKey $StorageAccountKey …
7
votes
1 answer

Add many domains to an azure web site

I'm migrating a pretty serious multi-tenant application to Azure, and one of the challenges I see coming is that it hosts over a hundred domains. On the Azure side, the only way I see to add a custom domain is hand-entering them via the portal. I…
Brian MacKay
  • 31,133
  • 17
  • 86
  • 125
6
votes
0 answers

Azure DevOps showing "failed" Status under commit history when build is partially succeeded (should show "warning" or similar)

In my pipeline I have a task (among others) that either succeeds or succeeds with issues, controlled by: if (-Not $packagesAreUpToDate) {Write-Host "##vso[task.complete result=SucceededWithIssues;]"} This task makes the entire job (containing other…
Haris H
  • 61
  • 2
6
votes
1 answer

Azure vnet / subnet list connected devices

I'm trying to write a PowerShell script that lists me all connected devices with there ips in my subnets in all VNets in all subscriptions. UPDATE the below script works, scroll down for original problem. $subs = Get-AzSubscription foreach ($Sub…
E. Staal
  • 525
  • 5
  • 18
6
votes
1 answer

Saving Powershell Object CSV String as a file to Azure Blob Storage

We are generating a Powershell object thru Azure Runbook and basically converting it into a CSV string. We want to store this generated CSV String (generated from Azure Powershell Runbook) into Azure Blob Storage as a CSV File. Can someone help me…
user42012
  • 722
  • 12
  • 33
6
votes
4 answers

Azure DevOps Pipeline Azure Blob Storage upload file 403 Forbidden Exception

Summary I'm creating a CI/CD provisioning pipeline for a new Azure Storage Account within an Azure DevOps Pipeline and attempting to upload some files into the Blob Storage using AzCopy running from an Azure Powershell task in the pipeline. The…
SJB
  • 177
  • 1
  • 9
6
votes
2 answers

How to read and set DevOps Pipeline variables using Azure PowerShell?

I have an Azure Pipeline setup with MyVariable variable defined: How do I write Azure PowerShell Inline Script to read the variable, and set it to a value after some processing?
CSon
  • 61
  • 1
  • 1
  • 2
6
votes
1 answer

What is the difference between Login-AzureRmAccount and Connect-AzureRmAccount?

I tried to google this, but despite of many promising item in the search list, all of them are about ARM vs ASM or Add-AzureRmAccount vs Connect-AzureRmAccount. Both are ARM commands, and both pops up the interactive login. Maybe I am missing the…
g.pickardou
  • 32,346
  • 36
  • 123
  • 268
6
votes
4 answers

Use Azure CLI within Azure Powershell Task

I want to create a Powershell script which executes some AzureRm... commands and follows those up with some Az commands. Reason being that some commands are only available via Az. When trying to execute these scripts in a release pipeline, the…