Azure CLI和循环 [英] Azure CLI and loop

查看:47
本文介绍了Azure CLI和循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找出使用Azure CLI完成此操作的最佳方法,我想将大约50个自定义域添加到应用程序服务中.我使用Azure CLI来完成此任务:

I am trying to figure out the best way to accomplish this with Azure CLI, I have about 50 custom domains I'd like to add to an app service. I use Azure CLI to accomplish this:

az webapp config hostname add --resource-group MYRESOURCE_GROUP--webapp-name MYAPPSERVICE_NAME --hostname DOMAIN.COM

我可以继续复制并粘贴每个域,但是我宁愿使用脚本来完成它.

Sure I can go ahead and copy and paste each domain, but I rather do it with a script.

如何编写脚本来完成此任务?现在,我的域列表在txt文件中.

How can I write a script to accomplish this? Right now my the domain list is in a txt file.

谢谢!

推荐答案

一种解决方案是编写Powershell脚本.该脚本将读取您的txt文件并遍历您所有的域:

One solution is to write a powershell script. This script will read your txt file and loop thru all your domains:

foreach($line in Get-Content .\mycustomdomains.txt) {
  az webapp config hostname add --resource-group MYRESOURCE_GROUP --webapp-name MYAPPSERVICE_NAME --hostname $line
}

这篇关于Azure CLI和循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆