Esempio n. 1
0
        public async Task TenantLevelDeployment()
        {
            string deploymentName = Recording.GenerateAssetName("csharpsdktest");
            var    templateString = File.ReadAllText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "ScenarioTests", "tenant_level_template.json"));

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

            //Validate
            var rawValidationResult = await DeploymentsOperations.StartValidateAtTenantScopeAsync(deploymentName, 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.StartCreateOrUpdateAtTenantScopeAsync(deploymentName, parameters);

            await WaitForCompletionAsync(deploymentResult);

            var deployment = (await DeploymentsOperations.GetAtTenantScopeAsync(deploymentName)).Value;

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

            var deploymentOperations = await DeploymentOperations.ListAtTenantScopeAsync(deploymentName).ToEnumerableAsync();

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