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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With