简体   繁体   English

如何在 Azure CI/CD 中使用 Azure CLI 步骤中的变量

[英]How to use variables in Azure CLI step in Azure CI/CD

I'm trying to deploy my configuration settings using Azure CLI step in my release pipeline.我正在尝试使用发布管道中的 Azure CLI 步骤部署我的配置设置。

There are multiple commands in it that I need to run which looks like this.我需要运行其中的多个命令,如下所示。

 - *az webapp config settings set -g resourceGroupName -n WebAppName
   --settings somekey=somevalue*

Note that There is a resourcegroupname and webappname that are present in it.请注意,其中存在resourcegroupname组名称和webappname How Can I create a Variable for those two values and use them in my CLI.如何为这两个值创建一个变量并在我的 CLI 中使用它们。 I have tried adding them to the arguments but it didn't work.我尝试将它们添加到 arguments 但它没有用。

Getting below error低于错误

validation error: Parameter 'resource_group_name' must conform to the following pattern: '^[-\\w\\._\\(\\)]+[^\\.]$'.

The reason being that I have 30 odd values and I need to create those variables for webapp which is present in multiple resource groups, So that I can simply swap the name of resource group and run the CLI.原因是我有 30 个奇数值,我需要为多个资源组中存在的 webapp 创建这些变量,这样我就可以简单地交换资源组的名称并运行 CLI。

You need to define variable in your pipeline and then use them in Azure Cli step.您需要在管道中定义变量,然后在 Azure Cli 步骤中使用它们。

在此处输入图像描述

So if you have variable named ResourceGroup you should have所以如果你有名为ResourceGroup的变量,你应该有

az webapp config settings set -g $(ResourceGroup) -n WebAppName --settings somekey=somevalue

You can also create variable group and reuse it across your pipelines.您还可以创建变量组并在您的管道中重复使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM