azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

New-AzureRmResourceGroupDeployment doesn't pass secureString when using templateURI

Open tombromby opened this issue 10 years ago • 9 comments

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

tombromby avatar Aug 03 '16 11:08 tombromby

@gaurav, can you take a look?

markcowl avatar Aug 03 '16 20:08 markcowl

Investigating

ravbhatnagar avatar Oct 10 '16 17:10 ravbhatnagar

@ravbhatnagar Are you still "investigating"?

ghost avatar Jan 17 '18 12:01 ghost

@ravbhatnagar are you able to help me out. Have got the same problem when using Visual Studio ARM template

vinayakmoh avatar Mar 20 '18 14:03 vinayakmoh

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/

marknettle avatar Jul 05 '18 03:07 marknettle

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.

johnnephin avatar Sep 07 '18 12:09 johnnephin

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

rajcheval avatar Oct 17 '18 14:10 rajcheval

: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

torreymicrosoft avatar Apr 22 '26 21:04 torreymicrosoft