2023-12-19 02:27:45 +08:00
|
|
|
Param(
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
|
|
[int]$KeyNumber
|
|
|
|
)
|
2023-06-07 06:03:50 +08:00
|
|
|
|
|
|
|
function Get-SasToken {
|
|
|
|
Param(
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
|
|
[int]$KeyNumber,
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
|
|
[ValidateNotNullOrEmpty()]
|
|
|
|
[string]$ResourceGroupName,
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
|
|
[ValidateNotNullOrEmpty()]
|
|
|
|
[string]$StorageAccountName,
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
|
|
[ValidateNotNullOrEmpty()]
|
|
|
|
[string]$ContainerName,
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
|
|
[ValidateNotNullOrEmpty()]
|
|
|
|
[string]$Permission
|
|
|
|
)
|
|
|
|
|
|
|
|
$keys = Get-AzStorageAccountKey -ResourceGroupName $ResourceGroupName -Name $StorageAccountName
|
|
|
|
$key = $keys[$KeyNumber - 1]
|
|
|
|
$ctx = New-AzStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $key.Value
|
|
|
|
$start = Get-Date -AsUTC
|
|
|
|
$end = $start.AddDays(90)
|
|
|
|
$token = New-AzStorageContainerSASToken -Name $ContainerName -Permission $Permission -StartTime $start -ExpiryTime $end -Context $ctx
|
|
|
|
return $token.Substring(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
# Asset Cache:
|
|
|
|
# Read, Create, List
|
2024-02-13 07:07:57 +08:00
|
|
|
$assetWus3Sas = Get-SasToken -KeyNumber $KeyNumber -ResourceGroupName vcpkg-asset-cache -StorageAccountName vcpkgassetcachewus3 -ContainerName cache -Permission rcl
|
2023-06-07 06:03:50 +08:00
|
|
|
|
|
|
|
# Binary Cache:
|
|
|
|
# Read, Create, List, Write
|
2023-12-19 02:27:45 +08:00
|
|
|
$binaryWUS3as = Get-SasToken -KeyNumber $KeyNumber -ResourceGroupName vcpkg-binary-cache -StorageAccountName vcpkgbinarycachewus3 -ContainerName cache -Permission rclw
|
2023-06-07 06:03:50 +08:00
|
|
|
|
|
|
|
$response = "Asset Cache SAS: Update`n" + `
|
|
|
|
"https://dev.azure.com/vcpkg/public/_library?itemType=VariableGroups&view=VariableGroupView&variableGroupId=6&path=vcpkg-asset-caching-credentials`n" + `
|
|
|
|
"and`n" + `
|
|
|
|
"https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_library?itemType=VariableGroups&view=VariableGroupView&variableGroupId=355&path=vcpkg-asset-caching-credentials`n" + `
|
|
|
|
"`n" + `
|
2024-02-13 07:07:57 +08:00
|
|
|
"wus3 token:`n" + `
|
|
|
|
"$assetWus3Sas`n" + `
|
2023-06-07 06:03:50 +08:00
|
|
|
"`n" + `
|
|
|
|
"Binary Cache SAS: Update`n" + `
|
|
|
|
"https://dev.azure.com/vcpkg/public/_library?itemType=VariableGroups&view=VariableGroupView&variableGroupId=8&path=vcpkg-binary-caching-credentials`n" + `
|
|
|
|
"`n" + `
|
2023-08-08 12:22:34 +08:00
|
|
|
"sas-bin-wus3:`n" + `
|
|
|
|
"$binaryWUS3as`n"
|
2023-06-07 06:03:50 +08:00
|
|
|
|
|
|
|
Write-Host $response
|