如何使用Azure CLI在现有的SQL Server上分配新标签?

huangapple go评论65阅读模式
英文:

How to assign a new tag on existing SQL Server using Azure CLI?

问题

Azure CLI文档中,我可以看到如何在我的资源上创建标签。它按预期工作。然而,指定ID有点繁琐,所以我想知道是否有一种只知道资源名称就能添加标签的方法。

自然而然,我可以执行以下操作。

$SqlServerId = az sql server show `
                 --resource-group ressy-grouppie `
                 --name sql-servy-v12 `
                 --query "id"
az tag create --resource-id $SqlServerId --tags monkey=donkey

但如果有一种更简短的方法,而不必实际创建保存ID的中间值,那就更好了。似乎Azure CLI的一般哲学是不仅通过ID,还要通过名称引用事物。

英文:

In docs for Azure CLI I can see how to create a tag on my resource. It works as supposed to. However, it's clunky to specify the ID, so I wonder if there's a way to add tag to a resource only knowing its name.

Naturally, I could do the following.

$SqlServerId = az sql server show `
                 --resource-group ressy-grouppie `
                 --name sql-servy-v12 `
                 --query "id"
az tag create --resource-id $SqlServerId --tags monkey=donkey

But I can't help if there's a shorter way, without actually creating the intermediate value holding the ID. It seems like the general philosophy of the Azure CLI is to refer to things by their names not only IDs.

答案1

得分: 1

抱歉,我只能为您提供翻译文本,不会回答问题。以下是翻译的内容:

Azure CLI的一般理念似乎是不仅通过名称而不仅是ID来引用事物。

不幸的是,在Azure服务中,您不能只使用资源的名称来创建标签,创建标签命令的功能需要资源的资源ID,而不仅仅是名称。

Sql服务器的资源ID是:

/subscriptions/xxx/resourceGroups/yyy/providers/Microsoft.Sql/servers/zzz

这里的xxx是订阅ID
yyy是资源组的名称
zzz是服务器的名称

所以ID并没有那么不同。

而且截止到今天,唯一的做法就是您已经采取的方式:【插入的图片链接】。

英文:

>It seems like the general philosophy of the Azure CLI is to refer to things by their names not only IDs.

Unfortunately, You cannot create a tag on a resource in Azure Services by just using its name, The functionality of creating a tag command requires the resource id of the resource and not just the name.

Resource id for Sql server is :

/subscriptions/xxx/resourceGroups/yyy/providers/Microsoft.Sql/servers/zzz

Here xxx is subscription id
yyy is name of the resource group
zzz is name of the server

So id not so different.

And currently as of today, the only way of doing this is the way you have done:

如何使用Azure CLI在现有的SQL Server上分配新标签?

如何使用Azure CLI在现有的SQL Server上分配新标签?

huangapple
  • 本文由 发表于 2023年6月1日 13:52:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/76379010.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定