Title
p

powerful-football-81694

03/07/2021, 10:58 PM
Hey guys, I’m almost there now with our migration to AzureNative. Just struggling to migrate our TemplateDeployment stuff, it seems Pulumi no longer likes it when we supply parameters with an anonymous object, like so:
return new DeploymentArgs()
{
	DeploymentName = "hostname-binding-template",
	ResourceGroupName = resourceGroupName,
	Location = location,
	Properties = new DeploymentPropertiesArgs()
	{
		Mode = DeploymentMode.Incremental,
		Parameters = new
		{
			webAppName = webAppName,
			hostname = hostname,
			sslState = sslState.ToString(),
			thumbprint = thumbprint
		},
		Template = templateJson
	}
};
This gets us an exception when running
pulumi up
:
System.InvalidOperationException: <>f__AnonymousType0`4[[Pulumi.Input`1[[System.String, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], Pulumi, Version=2.21.2.0, Culture=neutral, PublicKeyToken=null],[Pulumi.Input`1[[System.String, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], Pulumi, Version=2.21.2.0, Culture=neutral, PublicKeyToken=null],[System.String, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Pulumi.Input`1[[System.String, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], Pulumi, Version=2.21.2.0, Culture=neutral, PublicKeyToken=null]] is not a supported argument type.
So I checked the XML docs for the
Parameters
property, which say:
// Summary:
//     Name and value pairs that define the deployment parameters for the template.
//     You use this element when you want to provide the parameter values directly in
//     the request rather than link to an existing parameter file. Use either the parametersLink
//     property or the parameters property, but not both. It can be a JObject or a well
//     formed JSON string.
[Input("parameters", false, false)]
public Input<object>? Parameters { get; set; }
So I tried a JSON string instead, but then we get a different error:
error: azure-native:resources:Deployment resource 'hostname-binding-template' has a problem: 'properties.parameters' should be of type '' but got a string
Can someone tell me how I should pass the parameters now? With the old provider, the anonymous object approach worked fine. The C# examples here don’t give any hint - they are even incorrect C# syntax (value for the
Parameters
property is just missing from the code snippet: https://www.pulumi.com/docs/reference/pkg/azure-native/resources/deployment/
t

tall-librarian-49374

03/08/2021, 7:02 AM
I believe it expects a dictionary right now.
new Dictionary<string, object>...
p

powerful-football-81694

03/08/2021, 9:40 AM
OK, thanks I’ll try that - should it be a dictionary of
Input<T>
or should the values be resolved before @tall-librarian-49374?
And what does it expect for the template itself now? A well-formed JSON string does not seem to work.
Diagnostics:
  azure-native:resources:Deployment (hostname-binding-template):
    error: azure-native:resources:Deployment resource 'hostname-binding-template' has a problem: 'properties.template' should be of type '' but got a string
Tried both
System.Text.Json.JsonDocument
and
JObject
but neither works.
Diagnostics:
  pulumi:pulumi:Stack (SvcDownload-dev):
    error: Running program '/Users/danielrosenberg/Git/OrgFlow/SvcDownload/infra/bin/Debug/netcoreapp3.1/OrgFlow.Download.Pulumi.dll' failed with an unhandled exception:
    System.InvalidOperationException: System.Text.Json.JsonDocument is not a supported argument type.
        resource:hostname-binding-template[azure-native:resources:Deployment].properties.id.template.id
t

tall-librarian-49374

03/08/2021, 10:44 AM
same, dictionaries
I can see how this could be painful. Mind filing an issue for that?
p

powerful-football-81694

03/08/2021, 11:52 AM
Sure, if you promise not to lose it 😉
But, I’m not sure I understand
You’re saying a whole ARM template needs to be represented as a dictionary?
In the meantime, how can I work around this? Could I use the TemplateDeployment resource from the old provider as a stop-gap?
t

tall-librarian-49374

03/08/2021, 11:57 AM
Yes, you can. Or, make a helper function to convert your JSON to dictionaries recursively.
p

powerful-football-81694

03/08/2021, 12:07 PM
@tall-librarian-49374 turns out that, for the parameters dictionary, you also now have to “wrap” each value, from this:
"sku": "Dynamic",
"skuCode": "Y1",
into this:
"sku": {
    "value": "Dynamic"
},
"skuCode": {
    "value": "Y1"
},
To match what ARM expects. I think it would be a huge improvement if the new provider did this for you (like the old one did).
I’ll add it to the issue.
Anyway, with that out of the way, I hit the next road block:
Diagnostics:
  azure-native:resources:Deployment (hostname-binding-template):
    error: Code="InvalidDeployment" Message="The 'location' property is not allowed for a deployment at resource group scope. Please see <https://aka.ms/deploy-to-subscription> for usage details."
I’m not specifying the “location” property anywhere, neither in the template JSON nor in the resource properties.
Any idea how to get around that one?
t

tall-librarian-49374

03/08/2021, 12:51 PM
I think it would be a huge improvement if the new provider did this for you (like the old one did).
This is unlikely for now. Our current approach is staying true to the specs (even if they are sub-optimal).
p

powerful-football-81694

03/08/2021, 12:54 PM
Our current approach is staying true to the specs
I can appreciate that. A workaround is not too difficult, and the need for templated deployments should be almost zero with the new provider anyway.
t

tall-librarian-49374

03/08/2021, 12:54 PM
Any idea how to get around that one?
Ouch, that’s not good. Could you try setting
location
to null in your code?
p

powerful-football-81694

03/08/2021, 12:54 PM
Yeah - on the
DeploymentArgs
object you mean, or in the template JSON?
t

tall-librarian-49374

03/08/2021, 12:54 PM
In the args
p

powerful-football-81694

03/08/2021, 12:55 PM
same message 😕
t

tall-librarian-49374

03/08/2021, 12:56 PM
It’s our auto-location feature kicking in… in a bad way, it seems.
yeah… I can’t think of a workaround for this
p

powerful-football-81694

03/08/2021, 12:59 PM
ouch.. hmm
What about a fix?
t

tall-librarian-49374

03/08/2021, 2:51 PM
It can be fixed
p

powerful-football-81694

03/08/2021, 3:31 PM
Ok good. You need me to submit an issue?
t

tall-librarian-49374

03/08/2021, 3:40 PM
Yes please
p

powerful-football-81694

03/08/2021, 4:00 PM