Switch to User Delegate SAS for vcpkg caching (#5950)

This commit is contained in:
Wes Haggard 2024-08-30 10:33:47 -07:00 committed by GitHub
parent 7e9246794a
commit 11a61fa980
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 18 deletions

View File

@ -8,7 +8,7 @@ steps:
- task: AzurePowerShell@5
displayName: Set Vcpkg Write-mode Cache
inputs:
azureSubscription: 'cpp Resource Group'
azureSubscription: 'Azure SDK Artifacts'
ScriptType: FilePath
ScriptPath: eng/scripts/Set-VcpkgWriteModeCache.ps1
azurePowerShellVersion: LatestVersion

View File

@ -1,6 +1,5 @@
param(
[string] $StorageAccountName = 'cppvcpkgcache',
[string] $ResourceGroupName = 'cpp'
[string] $StorageAccountName = 'cppvcpkgcache'
)
@ -27,25 +26,15 @@ $env:PSModulePath = $modulePaths -join $moduleSeperator
Install-ModuleIfNotInstalled "Az.Storage" "4.3.0" | Import-Module
$storageAccountKeys = Get-AzStorageAccountKey `
-ResourceGroupName $ResourceGroupName `
-Name $StorageAccountName
$ctx = New-AzStorageContext `
-StorageAccountKey $storageAccountKeys[0].Value`
-StorageAccountName $StorageAccountName
-StorageAccountName $StorageAccountName `
-UseConnectedAccount
$token = New-AzStorageAccountSASToken `
-Service Blob `
-ResourceType Object `
$vcpkgBinarySourceSas = New-AzStorageContainerSASToken `
-Name $StorageAccountName `
-Permission "rwc" `
-Context $ctx `
-ExpiryTime (Get-Date).AddDays(1)
$vcpkgBinarySourceSas = $token
if ($token.StartsWith('?')) {
$vcpkgBinarySourceSas = $token.Substring(1)
}
-ExpiryTime (Get-Date).AddHours(1)
Write-Host "Ensure redaction of SAS tokens in logs"
Write-Host "##vso[task.setvariable variable=VCPKG_BINARY_SAS_TOKEN;issecret=true;]$vcpkgBinarySourceSas"