public void TenantLevelDeployment() { var handler = new RecordedDelegatingHandler() { StatusCodeToReturn = HttpStatusCode.Created }; using (MockContext context = MockContext.Start(this.GetType())) { var client = GetResourceManagementClient(context, handler); string deploymentName = TestUtilities.GenerateName("csharpsdktest"); var parameters = new ScopedDeployment { Properties = new DeploymentProperties() { Template = JObject.Parse(File.ReadAllText(Path.Combine("ScenarioTests", "tenant_level_template.json"))), Parameters = JObject.Parse("{'managementGroupId': {'value': 'tiano-mgtest01'}}"), Mode = DeploymentMode.Incremental, }, Location = "East US 2", Tags = new Dictionary <string, string> { { "tagKey1", "tagValue1" } } }; //Validate var validationResult = client.Deployments.ValidateAtTenantScope(deploymentName, parameters); //Assert Assert.Null(validationResult.Error); Assert.NotNull(validationResult.Properties); Assert.NotNull(validationResult.Properties.Providers); //Put deployment var deploymentResult = client.Deployments.CreateOrUpdateAtTenantScope(deploymentName, parameters); var deployment = client.Deployments.GetAtTenantScope(deploymentName); Assert.Equal("Succeeded", deployment.Properties.ProvisioningState); Assert.NotNull(deployment.Tags); Assert.True(deployment.Tags.ContainsKey("tagKey1")); var deploymentOperations = client.DeploymentOperations.ListAtTenantScope(deploymentName); Assert.Equal(4, deploymentOperations.Count()); } }
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()); }
public void ManagementGroupLevelDeployment() { var handler = new RecordedDelegatingHandler() { StatusCodeToReturn = HttpStatusCode.Created }; using (MockContext context = MockContext.Start(this.GetType())) { var client = GetResourceManagementClient(context, handler); string groupId = "tag-mg1"; string deploymentName = TestUtilities.GenerateName("csharpsdktest"); var parameters = new ScopedDeployment { Properties = new DeploymentProperties() { Template = JObject.Parse(File.ReadAllText(Path.Combine("ScenarioTests", "management_group_level_template.json"))), Parameters = JObject.Parse("{'storageAccountName': {'value': 'tagsa1'}}"), Mode = DeploymentMode.Incremental, }, Location = "East US" }; //Validate var validationResult = client.Deployments.ValidateAtManagementGroupScope(groupId, deploymentName, parameters); //Assert Assert.Null(validationResult.Error); Assert.NotNull(validationResult.Properties); Assert.NotNull(validationResult.Properties.Providers); //Put deployment var deploymentResult = client.Deployments.CreateOrUpdateAtManagementGroupScope(groupId, deploymentName, parameters); var deployment = client.Deployments.GetAtManagementGroupScope(groupId, deploymentName); Assert.Equal("Succeeded", deployment.Properties.ProvisioningState); } }
public static string SerializeScopeDeployment(ScopedDeployment deployment, JsonSerializerSettings settings) { CheckSerializationForDeploymentProperties(deployment.Properties); return(Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(deployment, settings)); }