Open mthamil opened 3 years ago
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Wmengmsft, @MehaKaushik, @shurd, @anfeldma-ms
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @armleads-azure.
Author: | mthamil |
---|---|
Assignees: | - |
Labels: | `ARM - Templates`, `Service Attention`, `customer-reported`, `question` |
Milestone: | - |
I'm seeing the exact same issue, but without an object
param. I first tried using a -TemplateParameterFile
arg, and I also tried using manually entered parameters, and got the same error with both:
Error reading JObject from JsonReader. Current JsonReader item is not an object: Null. Path '', line
| 1, position 4.
More info:
❯ $Error[0].Exception
LineNumber : 1
LinePosition : 4
Path :
TargetSite : Void HandleException(System.Runtime.ExceptionServices.ExceptionDispatchInfo)
StackTrace : at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.ResourceManagerCmdletBase.Handle
Exception(ExceptionDispatchInfo capturedException)
at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.ResourceManagerCmdletBase.Execut
eCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.<>c__3`1.<ExecuteSynchronously
OrAsJob>b__3_0(T c)
at
Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T
cmdlet, Action`1 executor)
at
Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T
cmdlet)
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Message : Error reading JObject from JsonReader. Current JsonReader item is not an object: Null. Path '', line
1, position 4.
Data : {}
InnerException :
HelpLink :
Source : Microsoft.Azure.PowerShell.Cmdlets.ResourceManager
HResult : -2146233088
It appears that the source of the exception is discarded, as there's no InnerException, and the stack trace just shows the HandleException
method.
I was able to work around this bug by validating an ARM template that references a template spec using templateLink.id
. In other works, I create the template spec like so:
$templateSpec = Set-AzTemplateSpec `
-Name $templateSpecName `
-Version $PackageVersion `
-Location $resourceGroupLocation `
-ResourceGroupName $ResourceGroupName `
-TemplateFile $rootTemplateFile
Then I have a validate.jsonc
ARM template that references the template spec:
"resources": [
{
"name": "linked-template-spec",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2020-10-01",
"properties": {
"mode": "Incremental",
"templateLink": {
"id": "[parameters('myTemplateSpecId')]"
},
"parameters": {
... (validation parameters)
Then I call Test-AzResourceGroupDeployment
on the validate.jsonc
template :
$templateSpecId = $templateSpec.Versions[0].Id
$validationResult = Test-AzResourceGroupDeployment `
-Mode Complete `
-ResourceGroupName $ResourceGroupName `
-TemplateFile "$PSScriptRoot/validate.jsonc" `
-TemplateParameterFile "$PSScriptRoot/validate.parameters.json" `
-myTemplateSpecId $templateSpecId `
-ErrorAction Continue
In other words, I can validate a template spec using a level of indirection, as long as I don't use a -TemplateSpecId
param when calling Test-AzResourceGroupDeployment
.
This is working well for me, but this issue still should be fixed.
Hello @mthamil Apologies for the delayed response. I see that this issue is opened a long time ago and no further activity had taken place. So wanted to check if you are still looking for assistance on this query? Please let us know.
Well, I ended up switching to the Azure CLI as a result. I do believe this is still an issue, though.
@SatishBoddu-MSFT - the bugs here still need to be fixed (I'm pretty sure). There should be tests for TestAzureResourceGroupDeploymentCmdlet
that use parameters, and the inner exception should not be discarded.
Thanks for the quick response on this issue.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @armleads-azure.
Author: | mthamil |
---|---|
Assignees: | - |
Labels: | `Service Attention`, `question`, `ARM - Templates`, `customer-reported`, `needs-team-attention` |
Milestone: | - |
@SatishBoddu-MSFT This issue still exists. Any updates since then?
Description
When using
TemplateSpecId
withTest-AzResourceGroupDeployment
orNew-AzResourceGroupDeployment
, theTemplateParameterObject
parameter is no longer available. It seems template parameters must be passed dynamically. I have attempted to use a hash and splat to pass these arguments as well as just explicitly, and with both methods I receive the following error:I have seen other issues that seem related like https://github.com/Azure/azure-powershell/issues/6292, but I updated both Powershell and the Az module and it persists.
Steps to reproduce
Create an ARM template that accepts an object parameter:
Create a template spec.
Try to validate the template.
Environment data
Module versions
Debug output
Error output