简体   繁体   English

如何使用 Azure CLI 将 vnet id 放入变量中

[英]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.

相关问题 如何使用 Azure CLI 将 Azure 容器实例部署到 VNET - How to deploy Azure Container Instance to VNET using Azure CLI Azure API 管理 - 如何使用 Azure CLI 设置 VNET/子网? - Azure API Management - How to set the VNET/SubNet using Azure CLI? 如何使用 ARM 模板将 Azure VM 添加到现有 Vnet 或新 Vnet - How can I add Azure VM to existing Vnet or new Vnet using ARM template 如何将 azure cli list 命令的值放入变量中? - how can i get the value of an azure cli list command into a variable? 如何将 azure cli 变量传递给 Azure Devops 变量? - How can i pass an azure cli variable to Azure Devops variables? 如何将azure应用服务计划连接到vnet,该vnet也通过对等连接到另一个vnet - How can I connect an azure app service plan to a vnet which is also connected through peering to another vnet 如何使用 az CLI 获取 Azure Log Analytics 的工作区 ID? - How to get workspace ID of Azure Log Analytics using az CLI? 如何使用 Azure CLI 获取安装了操作系统的 Azure VMS 列表? - how can i get a list of Azure VMS with operating system installed using Azure CLI? 使用Azure CLI或API的Web App Vnet集成 - Web App Vnet Integration using Azure CLI or API rest VNET 中的 Azure 容器实例如何获取 FQDN - Azure Container Instance in VNET how to get a FQDN
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM