question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to deploy using ARM template by passing the content of the json file.

See original GitHub issue

Hi folks,

I am trying to do a deployment but rather than passing the TemplateLink and ParametersLink, I’d rather passing the content. When I do so however I get an error as follows. What I do right now is simply loading the content of my template file

    public static Object GetTemplate() {
        return File.ReadAllText( @"E:\OfficialTemp\tmplt.json" ); }

    public static Object GetParameters(){
        return File.ReadAllText( @"E:\OfficialTemp\params.json"); }

and then in my main:

        deployment.Properties = new DeploymentProperties
        {
            Mode = DeploymentMode.Incremental,
            Template = GetTemplate(),
            Parameters = GetParameters(),
        };
         var resourceManagementClient = new ResourceManagementClient( credential )
        { SubscriptionId = subscriptionId };

        return await resourceManagementClient.Deployments.CreateOrUpdateAsync(
          groupName,
          deploymentName,
          deployment );

I’d like to mention that my tmplt.json and params.json are exactly the file that I used to in my deployment using the URI so I do not think that is an issue. (I get the error even when I use the values stated for template and parameters files in https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-windows-csharp-template/)

Error: System.AggregateException: One or more errors occurred. —> Microsoft.Rest.Azure.CloudException: The request content was invalid and could not be deserialized: 'Error converting value "


}" to type ‘Microsoft.WindowsAzure.ResourceStack.Frontdoor.Templates.Schema.Template’. Path ‘properties.template’, line 3, position 23171.'. at Microsoft.Azure.Management.ResourceManager.DeploymentsOperations.<BeginCreateOrUpdateWithHttpMessagesAsync>d__9.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Azure.Management.ResourceManager.DeploymentsOperations.<CreateOrUpdateWithHttpMessagesAsync>d__8.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Azure.Management.ResourceManager.DeploymentsOperationsExtensions.<CreateOrUpdateAsync>d__7.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at ConsoleApplication1.Program.<CreateTemplateDeploymentAsync>d__3.MoveNext() in

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
rshiranicommented, Jul 20, 2016

Thanks @devigned , it seems a bit tricky as we can pass string for template but not the parameter. I modified to this and now passes the json issue. Thanks for the link. That said I get a new exception (Long running operation failed with status ‘Failed’). Should I just retry or you have any other recommendations?

public static async Task<DeploymentExtended> CreateTemplateDeploymentAsync(
    TokenCredentials credential, 
    string groupName, 
    string deploymentName, 
    string subscriptionId)
{
    Console.WriteLine("Creating the template deployment...");
    var templateParams = new Dictionary<string, Dictionary<string, object>>{
        { "adminPassword", new Dictionary<string, object>{{"value","Azure1234567"}}},
        { "adminUserName", new Dictionary<string, object>{{"value", "davidmu" } }}
    };

    var deployment = new Deployment();
    deployment.Properties = new DeploymentProperties
    {
        Mode = DeploymentMode.Incremental,
        Template = JObject.Parse(File.ReadAllText("Templates\\CreateVMTemplate2.json")),
        Parameters = templateParams
    };
    var resourceManagementClient = new ResourceManagementClient(credential) { SubscriptionId = subscriptionId };
    return await resourceManagementClient.Deployments.CreateOrUpdateAsync(groupName, deploymentName, deployment);
}
0reactions
adrianhallcommented, Aug 7, 2019

This is an old issue. Is it still relevant?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Quickstart: Troubleshoot ARM template JSON deployments
This quickstart describes how to troubleshoot Azure Resource Manager template (ARM template) JSON deployment errors.
Read more >
Invalid template errors - Azure Resource Manager
Describes how to resolve invalid template errors when deploying Bicep files or Azure Resource Manager templates (ARM templates).
Read more >
Unable to pass parameters in powershell while deploying ...
The networkInterface successfully creates in my test resource groups using the default values from templates json file. My powershell deployment ...
Read more >
ARM Templates Parameter Files - YouTube
With JSON -based Parameter Files you can supply environment variables consistently and conviniently to your ARM Templates.
Read more >
Deploy and Configure Azure Resources with ARM Templates
From the Azure portal, navigate to Templates blade and, on the list of templates, click rg1-ARMTemplate, or whatever you called your template file...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found