Skip to content

Commit

Permalink
Switch to User Delegate SAS for vcpkg caching (#8907)
Browse files Browse the repository at this point in the history
  • Loading branch information
weshaggard authored Aug 30, 2024
1 parent 6550939 commit 0e3daff
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
20 changes: 12 additions & 8 deletions eng/scripts/Set-VcpkgWriteModeCache.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
param(
[string] $StorageAccountKey
[string] $StorageAccountName = 'cppvcpkgcache'
)


."$PSScriptRoot/../common/scripts/Helpers/PSModule-Helpers.ps1"

Write-Host "`$env:PSModulePath = $($env:PSModulePath)"
Expand All @@ -26,15 +27,18 @@ $env:PSModulePath = $modulePaths -join $moduleSeperator
Install-ModuleIfNotInstalled "Az.Storage" "4.3.0" | Import-Module

$ctx = New-AzStorageContext `
-StorageAccountName 'cppvcpkgcache' `
-StorageAccountKey $StorageAccountKey
$token = New-AzStorageAccountSASToken `
-Service Blob `
-ResourceType Object `
-StorageAccountName $StorageAccountName `
-UseConnectedAccount

$vcpkgBinarySourceSas = New-AzStorageContainerSASToken `
-Name $StorageAccountName `
-Permission "rwc" `
-Context $ctx `
-ExpiryTime (Get-Date).AddDays(1)
$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"

Write-Host "Setting vcpkg binary cache to read and write"
Write-Host "##vso[task.setvariable variable=VCPKG_BINARY_SOURCES_SECRET;issecret=true;]clear;x-azblob,https://cppvcpkgcache.blob.core.windows.net/public-vcpkg-container,$vcpkgBinarySourceSas,readwrite"
Write-Host "##vso[task.setvariable variable=X_VCPKG_ASSET_SOURCES_SECRET;issecret=true;]clear;x-azurl,https://cppvcpkgcache.blob.core.windows.net/public-vcpkg-asset-container/,?$vcpkgBinarySourceSas,readwrite"
14 changes: 9 additions & 5 deletions tools/apiview/parsers/cpp-api-parser/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,17 @@ stages:
displayName: Create cmake build directory.
workingDirectory: '$(Build.SourcesDirectory)/tools/apiview/parsers/cpp-api-parser'
condition: succeeded()
- task: PowerShell@2
- task: AzurePowerShell@5
displayName: Set Vcpkg Write-mode Cache
inputs:
azureSubscription: 'Azure SDK Artifacts'
ScriptType: FilePath
ScriptPath: eng/scripts/Set-VcpkgWriteModeCache.ps1
azurePowerShellVersion: LatestVersion
pwsh: true
targetType: filePath
filePath: eng/scripts/Set-VcpkgWriteModeCache.ps1
arguments: -StorageAccountKey '$(cpp-vcpkg-cache-storage-key)'
displayName: Set Vcpkg Write-mode Cache
# This step is idempotent and can be run multiple times in cases of
# failure and partial execution.
retryCountOnTaskFailure: 3
- pwsh: |
cmake.exe -G "Visual Studio 17 2022" -DCMAKE_CXX_STANDARD:STRING="20" -DCMAKE_TOOLCHAIN_FILE:STRING=${env:VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake -DVCPKG_BUILD_TYPE:STRING="release" -DVCPKG_OVERLAY_TRIPLETS:STRING="../vcpkg-triplets" -DMSVC_RUNTIME_LIBRARY:STRING="MultiThreadedDebug" -DVCPKG_TARGET_TRIPLET:STRING="x64-windows-static-release" ..
displayName: Cmake Generate.
Expand Down

0 comments on commit 0e3daff

Please sign in to comment.