Exemple #1
0
        public async Task WhatIfAtResourceGroup()
        {
            Subscription subscription = await Client.GetDefaultSubscriptionAsync();

            string            rgName = Recording.GenerateAssetName("testRg-5-");
            ResourceGroupData rgData = new ResourceGroupData(AzureLocation.WestUS2);
            var lro = await subscription.GetResourceGroups().CreateOrUpdateAsync(WaitUntil.Completed, rgName, rgData);

            ResourceGroup      rg = lro.Value;
            ResourceIdentifier deploymentResourceIdentifier = Deployment.CreateResourceIdentifier(rg.Id, "testDeploymentWhatIf");
            Deployment         deployment       = Client.GetDeployment(deploymentResourceIdentifier);
            DeploymentWhatIf   deploymentWhatIf = new DeploymentWhatIf(new DeploymentWhatIfProperties(DeploymentMode.Incremental)
            {
                Template   = CreateDeploymentPropertiesUsingString().Template,
                Parameters = CreateDeploymentPropertiesUsingJsonElement().Parameters
            });
            WhatIfOperationResult whatIfOperationResult = (await deployment.WhatIfAsync(WaitUntil.Completed, deploymentWhatIf)).Value;

            Assert.AreEqual(whatIfOperationResult.Status, "Succeeded");
            Assert.AreEqual(whatIfOperationResult.Changes.Count, 1);
            Assert.AreEqual(whatIfOperationResult.Changes[0].ChangeType, ChangeType.Create);
        }