azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

Set-AzureRmResource sets tags in lowercase for Microsoft.NotificationHubs/namespaces

Open sburkart80 opened this issue 8 years ago • 5 comments

Cmdlet(s) Set-AzureRmResource

PowerShell Version 5.1.15063.1112

Module Version 6.0.1

OS Version 1703 15063.1112

###Description When I use the Set-AzureRmResource cmdlet to configure tags on Microsoft.NotificationHubs resources (eg. namespaces) in Azure, the tag names are always set in lowercase. For example, when executing the command below, the tag name 'MyTag' will actually be configured in Azure as 'myTag'.

Set-AzureRmResource -ResourceId $resourceId -Tag @{ MyTag="test" }

Note the first character of the configured tag is lowercase instead of uppercase. This behaviour only occurs on Microsoft.NotificationHubs resources, as far as I have seen.

Script/Steps for Reproduction

Simply set a tag on a Microsoft.NotificationHubs resources in Azure using the Set-AzureRmResource cmdlet, for example a Azure namespace. In my case the first character of the tag name will always be lowercase.

Debug Output

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/02/2018 18:13:27:  - TokenCache: Serializing token cache with 2 items.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/02/2018 18:13:27:  - TokenCache: Serializing token cache with 2 items.
DEBUG: [Common.Authentication]: Authenticating using configuration values: Domain: '#HiddenForGithubIssue#', Endpoint: 'https://login.microsoftonline.com/', ClientId: '#HiddenForGithubIssue#', ClientRedirect:
'urn:ietf:wg:oauth:2.0:oob', ResourceClientUri: 'https://management.core.windows.net/', ValidateAuthrity: 'True'
DEBUG: [Common.Authentication]: Acquiring token using context with Authority 'https://login.microsoftonline.com/#HiddenForGithubIssue#/', CorrelationId: '00000000-0000-0000-0000-000000000000', ValidateAuthority: 'True'
DEBUG: [Common.Authentication]: Acquiring token using AdalConfiguration with Domain: '#HiddenForGithubIssue#', AdEndpoint: 'https://login.microsoftonline.com/', ClientId: '#HiddenForGithubIssue#', ClientRedirectUri:
urn:ietf:wg:oauth:2.0:oob
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/02/2018 18:13:27: #HiddenForGithubIssue# - AcquireTokenHandlerBase: === Token Acquisition started:
 Authority: https://login.microsoftonline.com/#HiddenForGithubIssue#/
 Resource: https://management.core.windows.net/
 ClientId: #HiddenForGithubIssue#
 CacheType: Microsoft.Azure.Commands.Common.Authentication.ProtectedFileTokenCache (2 items)
 Authentication Target: User

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/02/2018 18:13:27:  - TokenCache: Deserialized 2 items to token cache.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 06/02/2018 18:13:27: #HiddenForGithubIssue# - TokenCache: Looking up cache for a token...
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/02/2018 18:13:27: #HiddenForGithubIssue# - TokenCache: An item matching the requested resource was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 06/02/2018 18:13:27: #HiddenForGithubIssue# - TokenCache: 59.1338149933333 minutes left until token in cache expires
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/02/2018 18:13:27: #HiddenForGithubIssue# - TokenCache: A matching item (access token or refresh token or both) was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/02/2018 18:13:27: #HiddenForGithubIssue# - AcquireTokenHandlerBase: === Token Acquisition finished successfully. An access token was retuned:
 Access Token Hash: #HiddenForGithubIssue#
 Refresh Token Hash: #HiddenForGithubIssue#
 Expiration Time: 06/02/2018 19:12:35 +00:00
 User Hash: #HiddenForGithubIssue#

DEBUG: [Common.Authentication]: Received token with LoginType 'LiveId', Tenant: '#HiddenForGithubIssue#', UserId: '#HiddenForGithubIssue#'
DEBUG: [Common.Authentication]: Renewing Token with Type: 'Bearer', Expiry: '06/02/2018 19:12:35 +00:00', MultipleResource? 'True', Tenant: '#HiddenForGithubIssue#', UserId: '#HiddenForGithubIssue#'
DEBUG: [Common.Authentication]: User info for token DisplayId: '#HiddenForGithubIssue#', Name: #HiddenForGithubIssue#, IdProvider: 'https://sts.windows.net/#HiddenForGithubIssue#/', Uid: '36be2d35-03fa-4e08-8383-65025bb3de7c'
DEBUG: [Common.Authentication]: Checking token expiration, token expires '06/02/2018 19:12:35 +00:00' Comparing to '06/02/2018 18:13:27 +00:00' With threshold '00:05:00', calculated time until token expiry: '00:59:08.0288996'
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
PATCH

Absolute Uri:
https://management.azure.com/subscriptions/#HiddenForGithubIssue#/resourceGroups/#HiddenForGithubIssue#/providers/Microsoft.NotificationHubs/namespaces/#HiddenForGithubIssue#?api-version=2017-04-01

Headers:
User-Agent                    : AzurePowershell/v6.0.0,PSVersion/v5.1.15063.1112
ParameterSetName              : ByResourceId
CommandName                   : Set-AzureRmResource

Body:
{
  "tags": {
    "MyTag": "test"
  }
}

DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
Pragma                        : no-cache
x-ms-request-id               : 6f5cfd1f-7664-4778-aae6-363bb7a86d08_M8SN1_M8SN1
Server-SB                     : Service-Bus-Resource-Provider/SN1
Cache-Control                 : no-cache
Server                        : Service-Bus-Resource-Provider/SN1,Microsoft-HTTPAPI/2.0
x-ms-ratelimit-remaining-subscription-writes: 1199
x-ms-correlation-request-id   : 21539ec4-e0c9-4db1-a5cb-136b38dafe88
x-ms-routing-request-id       : WESTEUROPE:20180602T181328Z:21539ec4-e0c9-4db1-a5cb-136b38dafe88
Strict-Transport-Security     : max-age=31536000; includeSubDomains
X-Content-Type-Options        : nosniff
Date                          : Sat, 02 Jun 2018 18:13:27 GMT

Body:
{
  "id": null,
  "name": null,
  "type": null,
  "location": null,
  "tags": {
    "myTag": "test"
  },
  "properties": {
    "provisioningState": null,
    "metricId": null,
    "status": "Active",
    "createdAt": "2017-10-02T15:47:57.88Z",
    "serviceBusEndpoint": "https://#HiddenForGithubIssue#.servicebus.windows.net:443/",
    "enabled": true,
    "critical": false,
    "updatedAt": "2018-06-02T18:12:41.307Z",
    "namespaceType": "NotificationHub",
    "messagingSku": 1,
    "messagingSkuPlan": {
      "sku": 1,
      "selectedEventHubUnit": 1
    }
  }
}

DEBUG: [Common.Authentication]: Authenticating using Account: '#HiddenForGithubIssue#', environment: 'AzureCloud', tenant: '#HiddenForGithubIssue#'
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/02/2018 18:13:28:  - TokenCache: Serializing token cache with 2 items.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/02/2018 18:13:28:  - TokenCache: Serializing token cache with 2 items.
DEBUG: [Common.Authentication]: Authenticating using configuration values: Domain: '#HiddenForGithubIssue#', Endpoint: 'https://login.microsoftonline.com/', ClientId: '#HiddenForGithubIssue#', ClientRedirect:
'urn:ietf:wg:oauth:2.0:oob', ResourceClientUri: 'https://management.core.windows.net/', ValidateAuthrity: 'True'
DEBUG: [Common.Authentication]: Acquiring token using context with Authority 'https://login.microsoftonline.com/#HiddenForGithubIssue#/', CorrelationId: '00000000-0000-0000-0000-000000000000', ValidateAuthority: 'True'
DEBUG: [Common.Authentication]: Acquiring token using AdalConfiguration with Domain: '#HiddenForGithubIssue#', AdEndpoint: 'https://login.microsoftonline.com/', ClientId: '#HiddenForGithubIssue#', ClientRedirectUri:
urn:ietf:wg:oauth:2.0:oob
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/02/2018 18:13:28: afa44d3e-b8bc-480c-97b9-61c5ae4443f9 - AcquireTokenHandlerBase: === Token Acquisition started:
 Authority: https://login.microsoftonline.com/#HiddenForGithubIssue#/
 Resource: https://management.core.windows.net/
 ClientId: #HiddenForGithubIssue#
 CacheType: Microsoft.Azure.Commands.Common.Authentication.ProtectedFileTokenCache (2 items)
 Authentication Target: User

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/02/2018 18:13:28:  - TokenCache: Deserialized 2 items to token cache.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 06/02/2018 18:13:28: afa44d3e-b8bc-480c-97b9-61c5ae4443f9 - TokenCache: Looking up cache for a token...
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/02/2018 18:13:28: afa44d3e-b8bc-480c-97b9-61c5ae4443f9 - TokenCache: An item matching the requested resource was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 06/02/2018 18:13:28: afa44d3e-b8bc-480c-97b9-61c5ae4443f9 - TokenCache: 59.1051083683333 minutes left until token in cache expires
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/02/2018 18:13:28: afa44d3e-b8bc-480c-97b9-61c5ae4443f9 - TokenCache: A matching item (access token or refresh token or both) was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/02/2018 18:13:28: afa44d3e-b8bc-480c-97b9-61c5ae4443f9 - AcquireTokenHandlerBase: === Token Acquisition finished successfully. An access token was retuned:
 Access Token Hash: #HiddenForGithubIssue#
 Refresh Token Hash: #HiddenForGithubIssue#
 Expiration Time: 06/02/2018 19:12:35 +00:00
 User Hash: #HiddenForGithubIssue#

DEBUG: [Common.Authentication]: Received token with LoginType 'LiveId', Tenant: '#HiddenForGithubIssue#', UserId: '#HiddenForGithubIssue#'
DEBUG: [Common.Authentication]: Authenticating using Account: '#HiddenForGithubIssue#', environment: 'AzureCloud', tenant: '#HiddenForGithubIssue#'
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/02/2018 18:13:28:  - TokenCache: Serializing token cache with 2 items.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/02/2018 18:13:28:  - TokenCache: Serializing token cache with 2 items.
DEBUG: [Common.Authentication]: Authenticating using configuration values: Domain: '#HiddenForGithubIssue#', Endpoint: 'https://login.microsoftonline.com/', ClientId: '#HiddenForGithubIssue#', ClientRedirect:
'urn:ietf:wg:oauth:2.0:oob', ResourceClientUri: 'https://management.core.windows.net/', ValidateAuthrity: 'True'
DEBUG: [Common.Authentication]: Acquiring token using context with Authority 'https://login.microsoftonline.com/#HiddenForGithubIssue#/', CorrelationId: '00000000-0000-0000-0000-000000000000', ValidateAuthority: 'True'
DEBUG: [Common.Authentication]: Acquiring token using AdalConfiguration with Domain: '#HiddenForGithubIssue#', AdEndpoint: 'https://login.microsoftonline.com/', ClientId: '#HiddenForGithubIssue#', ClientRedirectUri:
urn:ietf:wg:oauth:2.0:oob
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/02/2018 18:13:28: c219a15f-166a-4aa9-b1e0-d8fe11697f41 - AcquireTokenHandlerBase: === Token Acquisition started:
 Authority: https://login.microsoftonline.com/#HiddenForGithubIssue#/
 Resource: https://management.core.windows.net/
 ClientId: #HiddenForGithubIssue#
 CacheType: Microsoft.Azure.Commands.Common.Authentication.ProtectedFileTokenCache (2 items)
 Authentication Target: User

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/02/2018 18:13:28:  - TokenCache: Deserialized 2 items to token cache.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 06/02/2018 18:13:28: c219a15f-166a-4aa9-b1e0-d8fe11697f41 - TokenCache: Looking up cache for a token...
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/02/2018 18:13:28: c219a15f-166a-4aa9-b1e0-d8fe11697f41 - TokenCache: An item matching the requested resource was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 06/02/2018 18:13:28: c219a15f-166a-4aa9-b1e0-d8fe11697f41 - TokenCache: 59.104237235 minutes left until token in cache expires
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/02/2018 18:13:28: c219a15f-166a-4aa9-b1e0-d8fe11697f41 - TokenCache: A matching item (access token or refresh token or both) was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/02/2018 18:13:28: c219a15f-166a-4aa9-b1e0-d8fe11697f41 - AcquireTokenHandlerBase: === Token Acquisition finished successfully. An access token was retuned:
 Access Token Hash: #HiddenForGithubIssue#
 Refresh Token Hash: #HiddenForGithubIssue#
 Expiration Time: 06/02/2018 19:12:35 +00:00
 User Hash: #HiddenForGithubIssue#

DEBUG: [Common.Authentication]: Received token with LoginType 'LiveId', Tenant: '#HiddenForGithubIssue#', UserId: '#HiddenForGithubIssue#'
DEBUG: [Common.Authentication]: Renewing Token with Type: 'Bearer', Expiry: '06/02/2018 19:12:35 +00:00', MultipleResource? 'True', Tenant: '#HiddenForGithubIssue#', UserId: '#HiddenForGithubIssue#'
DEBUG: [Common.Authentication]: User info for token DisplayId: '#HiddenForGithubIssue#', Name: #HiddenForGithubIssue#, IdProvider: 'https://sts.windows.net/#HiddenForGithubIssue#/', Uid: '36be2d35-03fa-4e08-8383-65025bb3de7c'
DEBUG: [Common.Authentication]: Checking token expiration, token expires '06/02/2018 19:12:35 +00:00' Comparing to '06/02/2018 18:13:28 +00:00' With threshold '00:05:00', calculated time until token expiry: '00:59:06.2542341'
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.azure.com/subscriptions/#HiddenForGithubIssue#/resourceGroups/#HiddenForGithubIssue#/providers/Microsoft.NotificationHubs/namespaces/#HiddenForGithubIssue#?api-version=2017-04-01

Headers:
User-Agent                    : AzurePowershell/v6.0.0,PSVersion/v5.1.15063.1112
ParameterSetName              : ByResourceId
CommandName                   : Set-AzureRmResource

Body:


DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
Pragma                        : no-cache
x-ms-request-id               : b492755a-bc88-4c5f-971f-6107715f5a2c_M4SN1_M4SN1
Server-SB                     : Service-Bus-Resource-Provider/SN1
Cache-Control                 : no-cache
Server                        : Service-Bus-Resource-Provider/SN1,Microsoft-HTTPAPI/2.0
x-ms-ratelimit-remaining-subscription-reads: 14999
x-ms-correlation-request-id   : 8a46f9c2-5112-41c4-80e5-5c0782431513
x-ms-routing-request-id       : WESTEUROPE:20180602T181329Z:8a46f9c2-5112-41c4-80e5-5c0782431513
Strict-Transport-Security     : max-age=31536000; includeSubDomains
X-Content-Type-Options        : nosniff
Date                          : Sat, 02 Jun 2018 18:13:29 GMT

Body:
{
  "id": "/subscriptions/#HiddenForGithubIssue#/resourceGroups/#HiddenForGithubIssue#/providers/Microsoft.NotificationHubs/namespaces/#HiddenForGithubIssue#",
  "name": "#HiddenForGithubIssue#",
  "type": "Microsoft.NotificationHubs/namespaces",
  "location": "West Europe",
  "kind": "NotificationHub",
  "sku": {
    "name": "Free"
  },
  "tags": {
    "myTag": "test"
  },
  "properties": {
    "provisioningState": "Succeeded",
    "metricId": null,
    "status": "Active",
    "createdAt": "2017-10-02T15:47:57.88Z",
    "serviceBusEndpoint": "https://#HiddenForGithubIssue#.servicebus.windows.net:443/",
    "enabled": true,
    "critical": false,
    "updatedAt": "2018-06-02T18:12:41.307Z",
    "namespaceType": "NotificationHub"
  }
}



Name              : #HiddenForGithubIssue#
ResourceId        : /subscriptions/#HiddenForGithubIssue#/resourceGroups/#HiddenForGithubIssue#/providers/Microsoft.NotificationHubs/namespaces/#HiddenForGithubIssue#
ResourceName      : #HiddenForGithubIssue#
ResourceType      : Microsoft.NotificationHubs/namespaces
Kind              : NotificationHub
ResourceGroupName : #HiddenForGithubIssue#
Location          : West Europe
SubscriptionId    : #HiddenForGithubIssue#
Tags              : {myTag}
Properties        : @{provisioningState=Succeeded; metricId=; status=Active; createdAt=2017-10-02T15:47:57.88Z; serviceBusEndpoint=https://#HiddenForGithubIssue#.servicebus.windows.net:443/; enabled=True; critical=False; updatedAt=2018-06-02T18:12:41.307Z;
                    namespaceType=NotificationHub}
Sku               : @{name=Free}

DEBUG: AzureQoSEvent: CommandName - Set-AzureRmResource; IsSuccess - True; Duration - 00:00:02.9989985; Exception - ;
DEBUG: Finish sending metric.
DEBUG: 20:13:31 - SetAzureResourceCmdlet end processing.
DEBUG: 20:13:31 - SetAzureResourceCmdlet end processing.

sburkart80 avatar Jun 02 '18 18:06 sburkart80

Confirmed that behavior is only found on NotificationHubs. Ex:

$a = set-azurermresource -ResourceId <notification hub resourceId> -Tag @{"A"="B"}
$a.Tags
Name                           Value
----                           -----
a                              B

Confirmed that tag is not set correctly for NotificationHub or NotificationHubNamespace, but correctly assigned for other resource types.

maddieclayton avatar Jun 20 '18 18:06 maddieclayton

@smithab Can you take a look at this issue? Case should be preserved for both the key and the value in a Tag.

maddieclayton avatar Jun 20 '18 18:06 maddieclayton

@smithab ping 😀

cormacpayne avatar Jul 02 '18 20:07 cormacpayne

Similar Issue for "Microsoft.Web/sites"

This is fine in the AzureRM Module but when using Az and Enable-AzureRmAlias it fudges the case

$tags = @{"UpperCaseKey" = "UpperCaseValue"}
Set-AzResource -ResourceGroupName ldtesting667 -ResourceName ldtesting667 -ResourceType "Microsoft.Web/sites" -Tag $tags -Force

$tags = (Get-AzResource -ResourceGroupName ldtesting667 -Name ldtesting667 -ResourceType "Microsoft.Web/sites").Tags


Key          Value
---          -----
upperCaseKey UpperCaseValue

LukeDearden avatar Oct 26 '18 10:10 LukeDearden

Please use Set-AzResource

RakeshMohanMSFT avatar Oct 21 '22 15:10 RakeshMohanMSFT