Пример #1
0
        public async Task DeploymentWithScope_AtManagementGroup()
        {
            string groupId        = "tag-mg1";
            string deploymentName = Recording.GenerateAssetName("csharpsdktest");
            string accountName    = Recording.GenerateAssetName("tagsa");
            var    templateString =
                File.ReadAllText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "ScenarioTests", "management_group_level_template.json"));

            var parameters = new Deployment
                             (
                new DeploymentProperties(DeploymentMode.Incremental)
            {
                Template   = templateString,
                Parameters = ("{'storageAccountName': {'value': '" + accountName + "'}}").Replace("'", "\"")
            }
                             )
            {
                Location = "East US",
                Tags     = new Dictionary <string, string> {
                    { "tagKey1", "tagValue1" }
                }
            };

            var managementGroupScope = $"//providers/Microsoft.Management/managementGroups/{groupId}";

            //Validate
            var rawValidationResult = await DeploymentsOperations.StartValidateAtScopeAsync(scope : managementGroupScope, deploymentName : deploymentName, parameters : parameters);

            var validationResult = (await WaitForCompletionAsync(rawValidationResult)).Value;

            //Assert
            Assert.Null(validationResult.Error);
            Assert.NotNull(validationResult.Properties);
            Assert.NotNull(validationResult.Properties.Providers);

            //Put deployment
            var deploymentResult = await DeploymentsOperations.StartCreateOrUpdateAtScopeAsync(scope : managementGroupScope, deploymentName : deploymentName, parameters : parameters);

            await WaitForCompletionAsync(deploymentResult);

            var deployment = (await DeploymentsOperations.GetAtScopeAsync(scope: managementGroupScope, deploymentName: deploymentName)).Value;

            Assert.AreEqual("Succeeded", deployment.Properties.ProvisioningState);
            Assert.NotNull(deployment.Tags);
            Assert.True(deployment.Tags.ContainsKey("tagKey1"));

            var deploymentOperations = await DeploymentOperations.ListAtScopeAsync(scope : managementGroupScope, deploymentName : deploymentName).ToEnumerableAsync();

            Assert.AreEqual(4, deploymentOperations.Count());
        }
Пример #2
0
        public async Task DeploymentWithScope_AtSubscription()
        {
            string groupName      = "SDK-test";
            string deploymentName = Recording.GenerateAssetName("csmd");
            var    templateString = File.ReadAllText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "ScenarioTests", "subscription_level_template.json"));

            var parameters = new Deployment
                             (
                new DeploymentProperties(DeploymentMode.Incremental)
            {
                Template   = templateString,
                Parameters = "{'storageAccountName': {'value': 'armbuilddemo1803'}}".Replace("'", "\"")
            }
                             )
            {
                Location = "WestUS",
                Tags     = new Dictionary <string, string> {
                    { "tagKey1", "tagValue1" }
                }
            };

            await ResourceGroupsOperations.CreateOrUpdateAsync(groupName, new ResourceGroup("WestUS"));

            var subscriptionScope = $"//subscriptions/{TestEnvironment.SubscriptionId}";

            //Validate
            var rawValidationResult = await DeploymentsOperations.StartValidateAtScopeAsync(scope : subscriptionScope, deploymentName : deploymentName, parameters : parameters);

            var validationResult = (await WaitForCompletionAsync(rawValidationResult)).Value;

            //Assert
            Assert.Null(validationResult.Error);
            Assert.NotNull(validationResult.Properties);
            Assert.NotNull(validationResult.Properties.Providers);

            //Put deployment
            var deploymentResult = await DeploymentsOperations.StartCreateOrUpdateAtScopeAsync(scope : subscriptionScope, deploymentName : deploymentName, parameters : parameters);

            await WaitForCompletionAsync(deploymentResult);

            var deployment = (await DeploymentsOperations.GetAtScopeAsync(scope: subscriptionScope, deploymentName: deploymentName)).Value;

            Assert.AreEqual("Succeeded", deployment.Properties.ProvisioningState);
            Assert.NotNull(deployment.Tags);
            Assert.True(deployment.Tags.ContainsKey("tagKey1"));

            var deploymentOperations = await DeploymentOperations.ListAtScopeAsync(scope : subscriptionScope, deploymentName : deploymentName).ToEnumerableAsync();

            Assert.AreEqual(4, deploymentOperations.Count());
        }
Пример #3
0
        public async Task DeploymentWithScope_AtTenant()
        {
            string deploymentName = Recording.GenerateAssetName("csharpsdktest");
            var    templateString = File.ReadAllText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "ScenarioTests", "tenant_level_template.json"));

            var parameters = new Deployment
                             (
                new DeploymentProperties(DeploymentMode.Incremental)
            {
                Template   = templateString,
                Parameters = "{'managementGroupId': {'value': 'tiano-mgtest01'}}".Replace("'", "\"")
            }
                             )
            {
                Location = "East US 2",
                Tags     = { { "tagKey1", "tagValue1" } }
            };

            //Validate
            var rawValidationResult = await DeploymentsOperations.StartValidateAtScopeAsync(scope : "", deploymentName : deploymentName, parameters : parameters);

            var validationResult = (await WaitForCompletionAsync(rawValidationResult)).Value;

            //Assert
            Assert.Null(validationResult.Error);
            Assert.NotNull(validationResult.Properties);
            Assert.NotNull(validationResult.Properties.Providers);

            //Put deployment
            var deploymentResult = await DeploymentsOperations.StartCreateOrUpdateAtScopeAsync(scope : "", deploymentName : deploymentName, parameters : parameters);

            await WaitForCompletionAsync(deploymentResult);

            var deployment = (await DeploymentsOperations.GetAtScopeAsync(scope: "", deploymentName: deploymentName)).Value;

            Assert.AreEqual("Succeeded", deployment.Properties.ProvisioningState);
            Assert.NotNull(deployment.Tags);
            Assert.True(deployment.Tags.ContainsKey("tagKey1"));

            var deploymentOperations = await DeploymentOperations.ListAtScopeAsync(scope : "", deploymentName : deploymentName).ToEnumerableAsync();

            Assert.AreEqual(4, deploymentOperations.Count());
        }