Create Pull Request
| Date | Scan | Status | Result |
|---|---|---|---|
| 2025-08-17 00:01 | #83 | cancelled |
Clean
|
| 2025-07-13 21:37 | #48 | completed |
Clean
|
| 2025-07-09 13:09 | #3 | cancelled |
Clean
|
| 2025-07-08 04:23 | #2 | cancelled |
Biased
|
# Define global variables for the script
$subscriptionName='<your subscription name>' # the name of subscription name you will use
$resourcegroupName = '<your resource group name>' # the name of resource group you will use
$storageAccountName= '<your storage account name>' # the storage account name you will use for backups
$containerName= '<your storage container name>' # the storage container name to which you will attach the SAS policy with its SAS token
$policyName = 'SASPolicy' # the name of the SAS policy
# adds an authenticated Azure account for use in the session
Login-AzAccount
# set the tenant, subscription and environment for use in the rest of
Select-AzSubscription -Subscription $subscriptionName
# Generate the SAS token
$sa = Get-AzStorageAccount -ResourceGroupName $resourcegroupName -Name $storageAccountName
$storagekey = Get-AzStorageAccountKey -ResourceGroupName $resourcegroupName -Name $storageAccountName
$storageContext = New-AzStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storagekey[0].Value
$cbc = Get-AzStorageContainer -Name $containerName -Context $storageContext
$policy = New-AzStorageContainerStoredAccessPolicy -Container $containerName -Policy $policyName -Context $storageContext -ExpiryTime $(Get-Date).ToUniversalTime().AddYears(10) -Permission "rwld"
$sas = New-AzStorageContainerSASToken -Policy $policyName -Context $storageContext -Container $containerName
Write-Host 'Shared Access Signature= '$($sas.Substring(1))''
# Outputs the Transact SQL to the clipboard and to the screen to create the credential using the Shared Access Signature
Write-Host 'Credential T-SQL'
$tSql = "CREATE CREDENTIAL [{0}] WITH IDENTITY='Shared Access Signature', SECRET='{1}'" -f $cbc.CloudBlobContainer.Uri.AbsoluteUri,$sas.Substring(1)
$tSql | clip
Write-Host $tSql