Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to User Delegate SAS for vcpkg caching #8907

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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