Use Azure federated auth (#5599)

This commit is contained in:
Daniel Jurek 2024-05-06 15:15:21 -07:00 committed by GitHub
parent c318b2f0f2
commit df8c4d4b2c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 9 deletions

View File

@ -4,11 +4,12 @@ steps:
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/,,read"
displayName: Set Vcpkg Variables
- task: PowerShell@2
inputs:
pwsh: true
targetType: filePath
filePath: eng/scripts/Set-VcpkgWriteModeCache.ps1
arguments: -StorageAccountKey '$(cpp-vcpkg-cache-storage-key)'
- task: AzurePowerShell@5
displayName: Set Vcpkg Write-mode Cache
condition: and(succeeded(), eq(variables['System.TeamProject'], 'internal'))
inputs:
azureSubscription: 'cpp Resource Group'
ScriptType: FilePath
ScriptPath: eng/scripts/Set-VcpkgWriteModeCache.ps1
azurePowerShellVersion: LatestVersion
pwsh: true

View File

@ -1,6 +1,6 @@
param(
[string] $StorageAccountName = 'cppvcpkgcache',
[string] $StorageAccountKey
[string] $ResourceGroupName = 'cpp'
)
@ -27,9 +27,14 @@ $env:PSModulePath = $modulePaths -join $moduleSeperator
Install-ModuleIfNotInstalled "Az.Storage" "4.3.0" | Import-Module
$storageAccountKeys = Get-AzStorageAccountKey `
-ResourceGroupName $ResourceGroupName `
-Name $StorageAccountName
$ctx = New-AzStorageContext `
-StorageAccountName $StorageAccountName `
-StorageAccountKey $StorageAccountKey
-StorageAccountKey $storageAccountKeys[0].Value`
-StorageAccountName $StorageAccountName
$token = New-AzStorageAccountSASToken `
-Service Blob `
-ResourceType Object `