Home > Blockchain >  PowerShell to turn on All network by Azure pipelines
PowerShell to turn on All network by Azure pipelines

Time:03-24

I wrote a power-shell and it is running fine from the windows machine by PS editor. System prompt for my user name to authenticate before running this.

$subscription = "dev"
Connect-AzAccount -Subscription $subscription
$keyvaultname = "kv-dev"
Update-AzKeyVaultNetworkRuleSet -DefaultAction Allow -VaultName $keyvaultname

when I am running the same script in Azure pipelines (using PowerShell task) it is throwing following error. I removed the Connect-AzAccount.

Update-AzKeyVaultNetworkRuleSet' 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, verify that the path is correct and try again.

How can I run this from azure pipelines using Power Shell task.

CodePudding user response:

To execute the Azure PowerShell commands in pipeline job to manage Azure resources, you should use the Azure PowerShell task instead of PowerShell task.

You need to set up an Azure Resource Manager service connection (ARM connection) for use on the Azure PowerShell task. This ARM connection is used as the authentication, and you should not directly set the authentication in the PowerShell scripts.

  • Related