From 76d9c46620c709a412895546d13ccfec8ea2f96b Mon Sep 17 00:00:00 2001 From: Brendan Kowitz Date: Wed, 25 Sep 2024 07:30:02 -0700 Subject: [PATCH] Fix storage cleanup script (#4644) --- build/jobs/clean-storage-accounts.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build/jobs/clean-storage-accounts.yml b/build/jobs/clean-storage-accounts.yml index e0098fc815..f9bb30ac9c 100644 --- a/build/jobs/clean-storage-accounts.yml +++ b/build/jobs/clean-storage-accounts.yml @@ -19,8 +19,10 @@ jobs: $storageAccounts = Get-AzStorageAccount -ResourceGroupName ${{ parameters.environmentName }} foreach ($storageAccount in $storageAccounts) { - - $storageContainers = Get-AzStorageContainer -Name * -Context $storageAccount.Context + # Create a storage context using Azure AD authentication + $ctx = New-AzStorageContext -StorageAccountName $storageAccount.StorageAccountName -UseConnectedAccount + + $storageContainers = Get-AzStorageContainer -Name * -Context $ctx foreach ($container in $storageContainers) { $ageDiff = $currentUtcTime - $container.CloudBlobContainer.Properties.LastModified.UtcDateTime if($ageDiff.TotalDays -ge 3) {