Skip to content

Update-AzTag takes 30 seconds when updating Managed Disk #22809

Open
@andyjballgit

Description

@andyjballgit

Description

Starting with Az.Resources version 6.9.0 , when performing at Update-AzTag on a managed disk , it takes approx 30 seconds to update the tag. Looking at the Debug output (v6.8.0 which takes around 1/2 second) , its seems to be using a different API Version for the Update tag and also running an API call to below url , that seems to account for the ~30 second delay :

https://management.azure.com/subscriptions/<subscription_id>/providers/Microsoft.Compute/locations/uksouth/DiskOperations/a48161a1-4ecc-4703-b4e1-588316563d80?p=993a60fa-f88e-474d-8f39-71d66ba1524a&monitor=true&api-version=2022-03-02

This issue occurs on Powershell 7.3.3 too

Issue script & Debug output

$ErrorActionPreference = "Stop"
# Region Change params 
$SubscriptionName = "<ChangeMe>"
$tenantid = "<ChangeMe>"
$Location = "uksouth"
$ResourceName = "SlowUpdateTagRepro"
$TagDesciptionString = ((Get-Date).ToString() + " " + ((Get-AzContext).Account) + " testing slow tag update" )
$UpdateTagOperation = "Merge"
$DeleteResourcesAfter = $true

$Tags = @{Test = "hello"
          Description =  $TagDesciptionString }
$ResourceGroupName = "RG-$ResourceName"

#endregion 

$DiskName = $ResourceName

Select-AzSubscription -SubscriptionName $SubscriptionName -Tenant $tenantid

New-AzResourceGroup -Name $ResourceGroupName -Location $Location -Force -verbose 

$DiskConfig = New-AzDiskConfig -Location $Location -DiskSizeGB 5 -SkuName Standard_LRS -OsType Windows -CreateOption Empty -EncryptionSettingsEnabled $false 
Write-Host "Creating Disk = $DiskName , RGName = $ResourceGroupName, Location = $Location" 

$objDisk = New-AzDisk -ResourceGroupName $ResourceGroupName -DiskName $DiskName -Disk $DiskConfig 

Write-Host ("`r`nRunning Update-AzTag with Operation = $UpdateTagOperation @ " + (Get-Date))

$DebugPreference = "Continue"
$objMeasure =  measure-command -Expression {Update-AzTag -ResourceId $objDisk.Id -Tag $Tags -Operation $UpdateTagOperation}
$DebugPreference = "SilentlyContinue" 

Write-Host ("`r`nUpdate-AzTag took = " + [math]::round($objMeasure.TotalMilliseconds,0) + " milliseconds")

Get-Module | Format-Table

If ($DeleteResourcesAfter -eq $true)
    {
        Write-Host ("`r`nDeleting ResourceGroup = $ResourceGroupName @ " + (Get-Date))
        $ret = Remove-AzResourceGroup -Name $ResourceGroupName -force -verbose 
    }


--
*** Debug output



DEBUG: 10:10:17 - UpdateAzureTagCommand begin processing with ParameterSet 'UpdateByResourceIdParameterSet'.
DEBUG: 10:10:17 - using account id '<users_upn>'...
DEBUG: 10:10:17 - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: [Common.Authentication]: Authenticating using Account: '<users_upn>', environment: 'AzureCloud', tenant: '<tenant_id>'
DEBUG: 10:10:17 - [ConfigManager] Got nothing from [EnableLoginByWam], Module = [], Cmdlet = []. Returning default value [False].
DEBUG: 10:10:17 - [SilentAuthenticator] Calling SharedTokenCacheCredential.GetTokenAsync - TenantId:'<tenant_id>', Scopes:'https://management.core.windows.net//.default', AuthorityHost:'https://login.microsoftonline.com/', UserId:'<users_upn>'
DEBUG: SharedTokenCacheCredential.GetToken invoked. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId: 
DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-09-18 09:10:17Z - 6e116158-f377-4b1c-920d-b78fa51f87a0] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-09-18 09:10:17Z - 6e116158-f377-4b1c-920d-b78fa51f87a0] [Region discovery] Not using a regional authority. 
DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-09-18 09:10:17Z - 6e116158-f377-4b1c-920d-b78fa51f87a0] [Region discovery] Not using a regional authority. 
DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-09-18 09:10:17Z - 6e116158-f377-4b1c-920d-b78fa51f87a0] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-09-18 09:10:17Z - 6e116158-f377-4b1c-920d-b78fa51f87a0] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-09-18 09:10:17Z] Found 1 cache accounts and 0 broker accounts
DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-09-18 09:10:17Z] Returning 1 accounts
DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-09-18 09:10:17Z - 9d7fb11e-218d-4e7b-9328-b94d34beb216] MSAL MSAL.Desktop with assembly version '4.49.1.0'. CorrelationId(9d7fb11e-218d-4e7b-9328-b94d34beb216)
DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-09-18 09:10:17Z - 9d7fb11e-218d-4e7b-9328-b94d34beb216] === AcquireTokenSilent Parameters ===
DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-09-18 09:10:17Z - 9d7fb11e-218d-4e7b-9328-b94d34beb216] LoginHint provided: False
DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-09-18 09:10:17Z - 9d7fb11e-218d-4e7b-9328-b94d34beb216] Account provided: True
DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-09-18 09:10:17Z - 9d7fb11e-218d-4e7b-9328-b94d34beb216] ForceRefresh: False
DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-09-18 09:10:17Z - 9d7fb11e-218d-4e7b-9328-b94d34beb216] 
=== Request Data ===
Authority Provided? - True
Scopes - https://management.core.windows.net//.default
Extra Query Params Keys (space separated) - 
ApiId - AcquireTokenSilent
IsConfidentialClient - False
SendX5C - False
LoginHint ? False
IsBrokerConfigured - False
HomeAccountId - False
CorrelationId - 9d7fb11e-218d-4e7b-9328-b94d34beb216
UserAssertion set: False
LongRunningOboCacheKey set: False
Region configured: 

DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-09-18 09:10:17Z - 9d7fb11e-218d-4e7b-9328-b94d34beb216] === Token Acquisition (SilentRequest) started:
	 Scopes: https://management.core.windows.net//.default
	Authority Host: login.microsoftonline.com
DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-09-18 09:10:17Z - 9d7fb11e-218d-4e7b-9328-b94d34beb216] [Region discovery] Not using a regional authority. 
DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-09-18 09:10:17Z - 9d7fb11e-218d-4e7b-9328-b94d34beb216] Access token is not expired. Returning the found cache entry. [Current time (09/18/2023 09:10:17) - Expiration Time (09/18/2023 10:15:18 +00:00) - Extended Expiration Time (
09/18/2023 10:15:18 +00:00)]
DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-09-18 09:10:17Z - 9d7fb11e-218d-4e7b-9328-b94d34beb216] Returning access token found in cache. RefreshOn exists ? False
DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-09-18 09:10:17Z - 9d7fb11e-218d-4e7b-9328-b94d34beb216] [Region discovery] Not using a regional authority. 
DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-09-18 09:10:17Z - 9d7fb11e-218d-4e7b-9328-b94d34beb216] 
	=== Token Acquisition finished successfully:
DEBUG: False MSAL 4.49.1.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-09-18 09:10:17Z - 9d7fb11e-218d-4e7b-9328-b94d34beb216]  AT expiration time: 18/09/2023 10:15:18 +00:00, scopes: https://management.core.windows.net//user_impersonation https://management.core.windows.net//.default. source: Cache
DEBUG: SharedTokenCacheCredential.GetToken succeeded. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId:  ExpiresOn: 2023-09-18T10:15:18.0000000+00:00
DEBUG: [Common.Authentication]: Received token with LoginType 'User', Tenant: '<tenant_id>', UserId: '<users_upn>'
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
PATCH

Absolute Uri:
https://management.azure.com//subscriptions/<subscription_id>/resourceGroups/<resourcegroup_name>/providers/Microsoft.Compute/disks/<disk_name>/providers/Microsoft.Resources/tags/default?api-version=2022-09-01

Headers:
x-ms-client-request-id        : 269fefc1-b889-44de-9116-06eecda7eb80
accept-language               : en-US

Body:
{
  "operation": "Merge",
  "properties": {
    "tags": {
      "testtag": "testtagupdated11",
      "<company_name>Identifier": "PLT00000072"
    }
  }
}


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

Status Code:
Accepted

Headers:
Pragma                        : no-cache
x-ms-ratelimit-remaining-subscription-writes: 1199
x-ms-request-id               : d42204c4-6a26-4036-bee5-5b4997c8ad52
x-ms-correlation-request-id   : d42204c4-6a26-4036-bee5-5b4997c8ad52
x-ms-routing-request-id       : UKSOUTH:20230918T091017Z:d42204c4-6a26-4036-bee5-5b4997c8ad52
Strict-Transport-Security     : max-age=31536000; includeSubDomains
X-Content-Type-Options        : nosniff
Cache-Control                 : no-cache
Date                          : Mon, 18 Sep 2023 09:10:17 GMT
Location                      : https://management.azure.com/subscriptions/<subscription_id>/providers/Microsoft.Compute/locations/uksouth/DiskOperations/a48161a1-4ecc-4703-b4e1-588316563d80?p=993a60fa-f88e-474d-8f39-71d66ba1524a&monitor=true&api-version=2022-03-02

Body:



DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.azure.com/subscriptions/<subscription_id>/providers/Microsoft.Compute/locations/uksouth/DiskOperations/a48161a1-4ecc-4703-b4e1-588316563d80?p=993a60fa-f88e-474d-8f39-71d66ba1524a&monitor=true&api-version=2022-03-02

Headers:
x-ms-client-request-id        : 269fefc1-b889-44de-9116-06eecda7eb80

Body:



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

Status Code:
OK

Headers:
Pragma                        : no-cache
x-ms-ratelimit-remaining-resource: Microsoft.Compute/GetOperation3Min;49996,Microsoft.Compute/GetOperation30Min;399988
Strict-Transport-Security     : max-age=31536000; includeSubDomains
x-ms-served-by                : 993a60fa-f88e-474d-8f39-71d66ba1524a_133052462204658961
x-ms-request-id               : b0592273-411d-4691-b2eb-8edf6b9ecff7
Cache-Control                 : no-cache
Server                        : Microsoft-HTTPAPI/2.0,Microsoft-HTTPAPI/2.0
x-ms-ratelimit-remaining-subscription-reads: 11999
x-ms-correlation-request-id   : 264f7996-0b0d-4882-9505-f5a9859b2322
x-ms-routing-request-id       : UKSOUTH:20230918T091047Z:264f7996-0b0d-4882-9505-f5a9859b2322
X-Content-Type-Options        : nosniff
Date                          : Mon, 18 Sep 2023 09:10:47 GMT

Body:
{
  "name": "<disk_name>",
  "id": "/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_name>/providers/Microsoft.Compute/disks/<disk_name>",
  "type": "Microsoft.Compute/disks",
  "location": "uksouth",
  "tags": {
    "ASR-ReplicaDisk": "<asr_replica_id>",
    "testtag": "testtagupdated11",
    "<company_name>Identifier": "PLT00000072"
  },
  "zones": [
    "1"
  ],
  "sku": {
    "name": "Standard_LRS",
    "tier": "Standard"
  },
  "properties": {
    "hyperVGeneration": "V2",
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 32,
    "diskIOPSReadWrite": 500,
    "diskMBpsReadWrite": 60,
    "encryption": {
      "type": "EncryptionAtRestWithCustomerKey",
      "diskEncryptionSetId": "/subscriptions/<subscription_id>/resourceGroups/CAF-RG-DISKENCRYPTION-KV-DEV/providers/Microsoft.Compute/diskEncryptionSets/cafdescmkhddevuks"
    },
    "networkAccessPolicy": "AllowAll",
    "publicNetworkAccess": "Enabled",
    "timeCreated": "2023-05-04T17:10:51.4024851+01:00",
    "provisioningState": "Succeeded",
    "diskState": "ActiveSAS",
    "diskSizeBytes": 34359738368,
    "uniqueId": "d4824d7d-aa91-46fd-bc65-73cbea53cfad"
  }
}


DEBUG: 10:10:48 - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 10:10:48 - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [False].
DEBUG: AzureQoSEvent:  Module: Az.Resources:6.9.0; CommandName: Update-AzTag; PSVersion: 5.1.22621.1778; IsSuccess: True; Duration: 00:00:30.4330630
DEBUG: 10:10:48 - [ConfigManager] Got nothing from [EnableDataCollection], Module = [], Cmdlet = []. Returning default value [True].

Environment data

Name                           Value                                                                                                                                                                                                                     
----                           -----                                                                                                                                                                                                                     
PSVersion                      5.1.22621.1778                                                                                                                                                                                                            
PSEdition                      Desktop                                                                                                                                                                                                                   
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                                                                   
BuildVersion                   10.0.22621.1778                                                                                                                                                                                                           
CLRVersion                     4.0.30319.42000                                                                                                                                                                                                           
WSManStackVersion              3.0                                                                                                                                                                                                                       
PSRemotingProtocolVersion      2.3                                                                                                                                                                                                                       
SerializationVersion           1.1.0.1

Module versions

ModuleType Version    Name                                ExportedCommands                                                                                                                                                                               
---------- -------    ----                                ----------------                                                                                                                                                                               
Script     2.13.0     Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault...}                                                                                                                       
Script     6.0.0      Az.Compute                          {Add-AzImageDataDisk, Add-AzVhd, Add-AzVMAdditionalUnattendContent, Add-AzVMDataDisk...}                                                                                                       
Script     6.9.0      Az.Resources                        {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAssignment, Get-AzDeployment...}                                                                                                     
Script     1.0.0.0    ISE                                 {Get-IseSnippet, Import-IseSnippet, New-IseSnippet}                                                                                                                                            
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}                                                                                                                             
Manifest   3.0.0.0    Microsoft.PowerShell.Security       {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Get-AuthenticodeSignature...}                                                                                                      
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}                                                                                                                                      
Manifest   3.0.0.0    Microsoft.WSMan.Management          {Connect-WSMan, Disable-WSManCredSSP, Disconnect-WSMan, Enable-WSManCredSSP...}

Error output

No Error - just long elapsed time

Metadata

Metadata

Assignees

No one assigned

    Labels

    ARM - TagsService AttentionThis issue is responsible by Azure service team.bugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reported

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions