admin管理员组文章数量:1124174
I'm having trouble determining a clear answer on tagging Service Principals as the documentation seems to say you can't do it () while several github and other resources have a command for it like so:
az ad sp update --id <service_principal_id> --add tags "<tag_key>=<tag_value>"
To confirm, I created a Service Principal in my private portal instance for test purposes. I played with it a bit and believe this code should be correct:
$sp = Get-AzADServicePrincipal -DisplayName "tempdelete"
$tags = @{"name"="value"}
Set-AzResource -ResourceId $sp.Id -Tag $tags
When I do this, I get the following error:
az account set --subscription <mysubid>
Set-AzResource: MissingSubscription : The request did not have a subscription or a valid tenant level resource provider.
CorrelationId: <some correlation id that changes every time>
The app is part of that subscription (it's my only subscription) and I'm not sure what I need to change to make this work.
I'm having trouble determining a clear answer on tagging Service Principals as the documentation seems to say you can't do it (https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/tag-support) while several github and other resources have a command for it like so:
az ad sp update --id <service_principal_id> --add tags "<tag_key>=<tag_value>"
To confirm, I created a Service Principal in my private portal instance for test purposes. I played with it a bit and believe this code should be correct:
$sp = Get-AzADServicePrincipal -DisplayName "tempdelete"
$tags = @{"name"="value"}
Set-AzResource -ResourceId $sp.Id -Tag $tags
When I do this, I get the following error:
az account set --subscription <mysubid>
Set-AzResource: MissingSubscription : The request did not have a subscription or a valid tenant level resource provider.
CorrelationId: <some correlation id that changes every time>
The app is part of that subscription (it's my only subscription) and I'm not sure what I need to change to make this work.
Share Improve this question asked yesterday not_a_generic_usernot_a_generic_user 2,1463 gold badges23 silver badges39 bronze badges 1- In Azure, tagging service principals directly is not supported in the same way that you can tag other Azure resources. The documentation you referenced correctly states that service principals do not have built-in support for tags. I cross checked with MS doc, there is --add but --add tag not there in documentation. – Arko Commented yesterday
1 Answer
Reset to default 1There are no particular tags for service principal. Tags will only support azure resources.
Alternatively, you can assign the tag name and tag values using notes. For reference check below-
az ad sp update --id '12345-11bc-123-456-57d4362d6ee9' --set notes="Tag: Env=dev"
az ad sp show --id '123457-17bc-4f0a-b432-abcdefgh'
You can also filter the application based on the tag value and tag name
az ad sp list --query "[?notes!=null && contains(notes, 'Tag: Env=dev')]" --all --output json
本文标签: command line interfaceHow can I apply namevalue tags to service principals in AzureStack Overflow
版权声明:本文标题:command line interface - How can I apply name=value tags to service principals in Azure? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736617717a1945507.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论