I'm generating a SAS token to access the linked templates in my ARM deployment. And I'm passing the SAS Token as a parameter override to the az deployment command. Turns out that my template deployment fails with the error "Unable to download deployment content from 'https://myLinkedTemplateURL?SASToken'
First, I fetch the storageAccountKey stored in a keyvault:
$storeKey = az keyvault secret show --name "myStorageSecretName" --vault-name "myKeyVaultName" --query value
$storeKey = $storeKey.Replace('"','')
Then, here's the two ways I'm generating the SAS Token:
SAS token generate by this method succeeds the deployment
$context = New-AzureStorageContext -StorageAccountName 'myStorageAccountName' -StorageAccountKey $storeKey $tokenval = New-AzureStorageContainerSASToken -Container builds -Permission rwdl -Context $context
SAS token generate by this method fails the deployment
$tokenval = az storage container generate-sas --account-key $storeKey --account-name "myStorageAccountName" --name "testcontainer" --permissions acdlrw --expiry (Get-Date).AddMinutes(30).ToString("yyyy-MM-dTH:mZ")
Also, I observe that the length of the SASToken generated by the second method is shorter than the first method.
Can someone please help shed some light on what's the difference between the above two methods and why one fails but the other succeeds?