AKS icon indicating copy to clipboard operation
AKS copied to clipboard

Error setting Azure-level Tags for AKS-created Resource Group (via API), though via Portal it works

Open davidcyr opened this issue 8 years ago • 4 comments

I have created an AKS cluster and am working on including automation to include Azure-level tags for management and cost reporting.

I am attempting to set Azure-level Tags of the Resource Group that AKS creates to manage its various resources (VNET, VMs, etc) in a PowerShell runbook with a script line like:

Set-AzureRmResourceGroup -Tag $tags -Name $SyntheticResourceGroupName and I receive the error message: "Set-AzureRmResourceGroup : The managed by property of the resource group cannot be changed from its current value"

I AM, however, able to set Tag values for the MC_<><><> Resource Group that AKS creates via the Portal.

Is there something special I need to do to set this via an API so I can include this logic in a RunBook?

davidcyr avatar May 01 '18 16:05 davidcyr

I encountered the same problem. The reason you can't use Set-AzureRmResourcegroup Cmd-Let is because it invokes the Service Management REST API, attempting to do a PUT. This fails because the PUT method indicates you want to replace the entity and there is a read-only property called managed by on the resource group. You can instead call the Service Management REST API with the PATCH method, to add/remove tags.

BlasterByte avatar Jun 03 '18 18:06 BlasterByte

But this needs then to be done outside the normal Cmd-Let calls, am I right?

Do you have an example how you did it?

sburkart80 avatar Jun 04 '18 07:06 sburkart80

I have uploaded a small example here: https://github.com/jdrask/Azure-Service-Management-PATCH-Example

BlasterByte avatar Jun 04 '18 09:06 BlasterByte

This is a known issue for repair on our roadmap.

jnoller avatar Apr 03 '19 20:04 jnoller