Ejemplo n.º 1
0
        public async Task ResourceGroupExistanceCheckTest()
        {
            // SET PARAMETERS
            var location               = Environment.GetEnvironmentVariable("AZURE_LOCATION");
            var baseUriString          = Environment.GetEnvironmentVariable("AZURE_BASE_URL");
            var resourceGroupName      = Environment.GetEnvironmentVariable("AZURE_RESOURCEGROUP");
            var servicePrincipalId     = Environment.GetEnvironmentVariable("AZURE_CLIENT_ID");
            var servicePrincipalSecret = Environment.GetEnvironmentVariable("AZURE_CLIENT_SECRET");
            var azureResourceId        = Environment.GetEnvironmentVariable("AZURE_RESOURCE_ID");
            var tenantId               = Environment.GetEnvironmentVariable("AZURE_TENANT_ID");
            var subscriptionId         = Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_ID");
            var credentials            = new CustomLoginCredentials(servicePrincipalId, servicePrincipalSecret, azureResourceId, tenantId);

            // SET CONTROLLER
            var resourceController = new ResourcesController(new Uri(baseUriString), credentials, subscriptionId);

            // CREATE RESOURCE GROUP
            var resourceGroup = await resourceController.CreateResourceGroup(resourceGroupName, location);

            // CREATE RESOURCE GROUP VALIDATION
            Assert.Equal("OK", resourceGroup.Response.ReasonPhrase, ignoreCase: true);
            Assert.NotNull(resourceGroup.Body);

            // CHECK RESOURCE GROUP
            var resourceGroupExistance = await resourceController.CheckResourceGroupExistance(resourceGroupName);

            // CHECK RESOURCE GROUP VALIDATION
            Assert.Equal("OK", resourceGroupExistance.Response.ReasonPhrase, ignoreCase: true);
            Assert.True(resourceGroupExistance.Body);
        }