[英]how can I get the vnet id into a variable using Azure CLI
I want to get the vnet id of an azure vnet into a variable using azure cli.我想使用 azure cli 将 azure vnet 的 vnet id 放入变量中。
i then want to use this variable in the azure devops pipeline and populate a variable there?然后我想在 azure devops 管道中使用这个变量并在那里填充一个变量?
How can i do this?我怎样才能做到这一点?
You can use the Azure CLI task making use of the az network vnet commands, eg您可以通过az network vnet命令使用Azure CLI 任务,例如
- task: AzureCLI@2
displayName: Azure CLI
inputs:
azureSubscription: <Name of the Azure Resource Manager service connection>
scriptType: ps
scriptLocation: inlineScript
inlineScript: |
az network vnet show -g MyResourceGroup -n MyVNet
In the same task's inline script you're free to use any powershell, so could also set variables in that script for use in subsequent steps.在同一任务的内联脚本中,您可以自由使用任何 powershell,因此也可以在该脚本中设置变量以供后续步骤使用。 Hope this helps!
希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.