New-AzureRmResourceGroupDeployment doesn't pass secureString when using templateURI
Not sure if this is something I'm doing wrong, but I seem to be unable to pass a secureString for _artifactsLocation parameter when using TemplateURI. TemplateFile seems to work fine. There is no meaningful error, just an indicatation that the secureString wasn't passed over
Code : InvalidTemplate
Message : Deployment template validation failed: 'The value for the template parameter '_artifactsLocationSasToken' at line '189' and column '36' is not provided
Fails:
New-AzureRmResourceGroupDeployment -ResourceGroupName $rg -TemplateUri $TemplateURI -TemplateParameterUri $TemplateParametersURI -_artifactsLocationSasToken $ArtifactsLocationSasToken
Works:
New-AzureRmResourceGroupDeployment -ResourceGroupName $rg -TemplateFile $TemplateLocalFile -TemplateParameterFile $TemplateParamLocalFile -_artifactsLocationSasToken $ArtifactsLocationSasToken
Above the previous commands is this part setting the SAS Token
$StorageAccountKey = (Get-AzureRmStorageAccountKey -ResourceGroupName $StorageAccountResourceGroupName -Name $StorageAccountName).Key1
$StorageAccountContext = (Get-AzureRmStorageAccount -ResourceGroupName $StorageAccountResourceGroupName -Name $StorageAccountName).Context
$ArtifactsLocationSasToken = New-AzureStorageContainerSASToken -Container $StorageContainerName -Context $StorageAccountContext -Permission r -ExpiryTime (Get-Date).AddHours(4)
$ArtifactsLocationSasTokenFile = New-AzureStorageContainerSASToken -Container $StorageContainerName -Context $StorageAccountContext -Permission r -ExpiryTime (Get-Date).AddHours(4)
$ArtifactsLocationSasToken = ConvertTo-SecureString $ArtifactsLocationSasToken -AsPlainText -Force
@gaurav, can you take a look?
Investigating
@ravbhatnagar Are you still "investigating"?
@ravbhatnagar are you able to help me out. Have got the same problem when using Visual Studio ARM template
Here's a workaround: https://blogs.msdn.microsoft.com/brian_farnhill/2017/09/14/the-provided-value-for-the-template-parameter-is-not-valid-in-arm-template-deployments/
Workaround does't seem to work for me with TemplateParameterUri when trying to pass a SAS token. Passing the parameters as TemplateParameterFile and then passing in the SAS token as an additional parameter works.
I am having the same problem. Visual studio code/Json lint do not show any errors in my template. I have verified that value of _artifactsLocationSasToken is being set to appropriate secure string. I am still getting error: A parameter cannot be found that matches parameter name '_artifactsLocationSasToken'.
New-AzureRmResourceGroupDeployment -Name ((Get-ChildItem $TemplateFile).BaseName + '-' + ((Get-Date).ToUniversalTime()).ToString('MMdd-HHmm')) `
-ResourceGroupName $ResourceGroupName `
@TemplateArgs `
@OptionalParameters `
-Force -Verbose `
-ErrorVariable ErrorMessages
Here is output of PS Version Table PS C:\git\worldviewinfra\src\firewall> $PSVersionTable
Name Value
PSVersion 5.1.17134.228 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.17134.228 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1
:bell: Routing this issue to @act-identity-squad.
@tombromby Thanks for the report. This affects AzureRM, which was retired on February 29, 2024. Please use New-AzResourceGroupDeployment from Az.Resources, which has had significant parameter-handling improvements since 2016.
Closing as obsolete. If secureString + TemplateUri is still broken on current Az.Resources, please open a new issue. @azcloudfarmer for vis