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.

[QUERY] WhatIf deployments in new SDK

See original GitHub issue

Library name and version

Azure.ResourceManager.Resources 1.0.0-beta.6

Query/Question

In previous versions of the SDK, it was possible to create a “WhatIf” deployment and execute it, as below:

ResourcesManagementClient client = ...

var whatIf = new DeploymentWhatIf(
    new DeploymentWhatIfProperties(DeploymentMode.Incremental)
    {
        Template = "Template stuff here"
    }
);

await (await client.Deployments.StartWhatIfAsync("MyResourceGroup", "MyDeployment", whatIf)).WaitForCompletionAsync();

Does the newer version of the SDK have a similar mechanism? I have found similar deployment classes, but they appear to be internalized.

Environment

No response

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
JayDZimmermancommented, Feb 22, 2022

@Yao725 That took care of it. The secret sauce was the “CreateResourceIdentifier” method, which solved my primary issue of not knowing how to create a deployment (without executing it as well). Thanks for your help.

0reactions
Yao725commented, Feb 21, 2022

@JayDZimmerman Yes, on line 11 the deployment will get executed, I use this because I want to get the WhatIf info which comparing to an existing deployment. For you scenario, I think you can take following code in which no deployments get executed as example:

ArmClient armClient = new ArmClient(new DefaultAzureCredential());
Subscription subscription = await armClient.GetDefaultSubscriptionAsync();
ResourceGroup rg = (await subscription.GetResourceGroups().CreateOrUpdateAsync(true, "testRg", new ResourceGroupData(AzureLocation.EastUS))).Value;
ResourceIdentifier deploymentIdentifier = Deployment.CreateResourceIdentifier(rg.Id.ToString(), "testDeployment");
Deployment deployment = armClient.GetDeployment(deploymentIdentifier);
DeploymentWhatIfProperties deploymentWhatIfProperties = new DeploymentWhatIfProperties(DeploymentMode.Incremental)
{
    TemplateLink = new TemplateLink
    {
        Uri = "https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/azure-resource-manager/what-if/what-if-after.json"
    }
};
var deploymentWhatIfOperation = await deployment.WhatIfAsync(true, string.Empty, deploymentWhatIfProperties);
Read more comments on GitHub >

github_iconTop Results From Across the Web

Deployments - What If - REST API (Azure Resource ...
Learn more about Resource Management service - Returns changes that will be made by the deployment if executed at the scope of the...
Read more >
Template deployment what-if - Azure Resource Manager
The what-if operation doesn't make any changes to existing resources. Instead, it predicts the changes if the specified template is deployed.
Read more >
ARM template deployment what-if operation - Evgeny Borzenin
Now, let's change sku from Standard_LRS to Standard_GRS and check the execution plan. New-AzResourceGroupDeployment -ResourceGroupName iac-what- ...
Read more >
ARM Template deployment, the what-if option for your ...
In this post, I will show you how to use the new what-if option in the PowerShell cmdlet and how to use it...
Read more >
Azure ARM Template Development — Validate with WhatIf
A local development PowerShell script for making ARM template testing easier with the new WhatIf Operation. Originally published at https://mertsenel.tech ...
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