Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there some tool/command to run azcli files from powershell?

I'm using VS Code, and to get some intellisense when writing the azure cli script I've put everything in a .azcli file. My question now is how do I execute that file from a powershell terminal? Also, is it possible to use parameters in such a script like:

az servicebus topic create -g $resourceGroup -n $topicName --namespace-name $namespace

Is it possible to call a azcli file that looks like the one above and provice the $resourceGroup, $topicName, $namespace as argument from powershell?

like image 522
Tomas Jansson Avatar asked Oct 16 '22 03:10

Tomas Jansson


1 Answers

I'm not aware of an easy way to do this in PowerShell. If someone knows, I would like to know as well.

If you have Windows Subsystem for Linux installed, you can run .azcli files just like .sh shell scripts inside WSL from PowerShell. WSL will need to have Azure CLI installed as well, so depending on the distribution you pick(Ubuntu or Debian are ussually safe), you will need to follow the instructions from Install the Azure CLI.

To run script in WSL from PowerShell terminal:

bash -c "./file.azcli"

Or directly in WSL terminal:

./file.azcli

You can use parameters in a .azcli file just like .sh shell scripts:

resourceGroup=MyRG
topicName=MyTopicName
namespace=myNameSpaceName

az servicebus topic create -g $resourceGroup -n $topicName --namespace-name $namespace

You could also create a .vscode/tasks.json, similar to what this GitHub issue recommends.

like image 128
RoadRunner Avatar answered Oct 19 '22 02:10

RoadRunner