コード例 #1
0
 /// <summary>
 /// Updates the Microsoft.ApiManagement resource running in the Virtual network
 /// to pick the updated network settings.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='serviceName'>
 /// The name of the API Management service.
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the Apply Network Configuration operation. If the
 /// parameters are empty, all the regions in which the Api Management service
 /// is deployed will be updated sequentially without incurring downtime in the
 /// region.
 /// </param>
 public static ApiManagementServiceResource BeginApplyNetworkConfigurationUpdates(this IApiManagementServiceOperations operations, string resourceGroupName, string serviceName, ApiManagementServiceApplyNetworkConfigurationParameters parameters = default(ApiManagementServiceApplyNetworkConfigurationParameters))
 {
     return(operations.BeginApplyNetworkConfigurationUpdatesAsync(resourceGroupName, serviceName, parameters).GetAwaiter().GetResult());
 }
コード例 #2
0
 /// <summary>
 /// Updates the Microsoft.ApiManagement resource running in the Virtual network
 /// to pick the updated network settings.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='serviceName'>
 /// The name of the API Management service.
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the Apply Network Configuration operation. If the
 /// parameters are empty, all the regions in which the Api Management service
 /// is deployed will be updated sequentially without incurring downtime in the
 /// region.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <ApiManagementServiceResource> BeginApplyNetworkConfigurationUpdatesAsync(this IApiManagementServiceOperations operations, string resourceGroupName, string serviceName, ApiManagementServiceApplyNetworkConfigurationParameters parameters = default(ApiManagementServiceApplyNetworkConfigurationParameters), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.BeginApplyNetworkConfigurationUpdatesWithHttpMessagesAsync(resourceGroupName, serviceName, parameters, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
コード例 #3
0
        public async Task CreateInVirtualNetworkStv1Tests()
        {
            Environment.SetEnvironmentVariable("AZURE_TEST_MODE", "Playback");
            using (MockContext context = MockContext.Start(this.GetType()))
            {
                var testBase = new ApiManagementTestBase(context);

                var virtualNetworkName = TestUtilities.GenerateName("apimvnet");
                var subnetName         = TestUtilities.GenerateName("apimsubnet");

                var vnet = new VirtualNetwork()
                {
                    Location = testBase.location,

                    AddressSpace = new AddressSpace()
                    {
                        AddressPrefixes = new List <string>()
                        {
                            "10.0.0.0/16",
                        }
                    },
                    Subnets = new List <Subnet>()
                    {
                        new Subnet()
                        {
                            Name          = subnetName,
                            AddressPrefix = "10.0.1.0/24",
                        },
                    }
                };

                // Put Vnet
                var putVnetResponse = testBase.networkClient.VirtualNetworks.CreateOrUpdate(testBase.rgName, virtualNetworkName, vnet);
                Assert.Equal("Succeeded", putVnetResponse.ProvisioningState);

                var getSubnetResponse = testBase.networkClient.Subnets.Get(testBase.rgName, virtualNetworkName, subnetName);
                Assert.NotNull(getSubnetResponse);
                Assert.NotNull(getSubnetResponse.Id);

                testBase.serviceProperties.VirtualNetworkType          = VirtualNetworkType.External;
                testBase.serviceProperties.VirtualNetworkConfiguration = new VirtualNetworkConfiguration()
                {
                    SubnetResourceId = getSubnetResponse.Id
                };

                var createdService = testBase.client.ApiManagementService.CreateOrUpdate(
                    resourceGroupName: testBase.rgName,
                    serviceName: testBase.serviceName,
                    parameters: testBase.serviceProperties);

                ValidateService(createdService,
                                testBase.serviceName,
                                testBase.rgName,
                                testBase.subscriptionId,
                                testBase.location,
                                testBase.serviceProperties.PublisherEmail,
                                testBase.serviceProperties.PublisherName,
                                testBase.serviceProperties.Sku.Name,
                                testBase.tags,
                                PlatformVersion.Stv1);

                Assert.Equal(VirtualNetworkType.External, createdService.VirtualNetworkType);
                Assert.NotNull(createdService.VirtualNetworkConfiguration);
                Assert.Equal(getSubnetResponse.Id, createdService.VirtualNetworkConfiguration.SubnetResourceId);

                // apply network configuration
                var applyNetworkConfigParameters = new ApiManagementServiceApplyNetworkConfigurationParameters()
                {
                    Location = createdService.Location
                };

                var applyNetworkServiceResponse = testBase.client.ApiManagementService.ApplyNetworkConfigurationUpdates(
                    resourceGroupName: testBase.rgName,
                    serviceName: testBase.serviceName,
                    parameters: applyNetworkConfigParameters);

                Assert.NotNull(applyNetworkServiceResponse);
                Assert.Equal(createdService.Name, applyNetworkServiceResponse.Name);
                Assert.NotNull(applyNetworkServiceResponse.VirtualNetworkConfiguration);
                Assert.Equal(VirtualNetworkType.External, applyNetworkServiceResponse.VirtualNetworkType);
                // get the network status by service
                var serviceNetworkStatus = await testBase.client.NetworkStatus.ListByServiceAsync(
                    testBase.rgName,
                    testBase.serviceName);

                Assert.NotNull(serviceNetworkStatus);
                Assert.Single(serviceNetworkStatus);
                Assert.Equal(testBase.location.ToLowerAndRemoveWhiteSpaces(), serviceNetworkStatus.First().Location.ToLowerAndRemoveWhiteSpaces());
                Assert.NotNull(serviceNetworkStatus.First().NetworkStatus.ConnectivityStatus);
                Assert.NotNull(serviceNetworkStatus.First().NetworkStatus.DnsServers);
                Assert.Equal("success", serviceNetworkStatus.First().NetworkStatus.ConnectivityStatus.First().Status, true);
                Assert.NotNull(serviceNetworkStatus.First().NetworkStatus.ConnectivityStatus.First().Name);
                Assert.NotNull(serviceNetworkStatus.First().NetworkStatus.ConnectivityStatus.First().ResourceType);

                // get the network status by location
                var serviceNetworkStatusByLocation = await testBase.client.NetworkStatus.ListByLocationAsync(
                    testBase.rgName,
                    testBase.serviceName,
                    createdService.Location);

                Assert.NotNull(serviceNetworkStatusByLocation);
                Assert.NotNull(serviceNetworkStatusByLocation.ConnectivityStatus);
                Assert.NotNull(serviceNetworkStatusByLocation.DnsServers);
                Assert.Equal("success", serviceNetworkStatusByLocation.ConnectivityStatus.First().Status, true);
                Assert.NotNull(serviceNetworkStatusByLocation.ConnectivityStatus.First().Name);

                // Move to Internal Virtual Network
                testBase.serviceProperties.VirtualNetworkType = VirtualNetworkType.Internal;
                var updatedService = testBase.client.ApiManagementService.CreateOrUpdate(
                    resourceGroupName: testBase.rgName,
                    serviceName: testBase.serviceName,
                    parameters: testBase.serviceProperties);
                Assert.Equal(VirtualNetworkType.Internal, updatedService.VirtualNetworkType);
                Assert.NotNull(updatedService.VirtualNetworkConfiguration);
                Assert.Equal(getSubnetResponse.Id, updatedService.VirtualNetworkConfiguration.SubnetResourceId);

                // Delete
                testBase.client.ApiManagementService.Delete(
                    resourceGroupName: testBase.rgName,
                    serviceName: testBase.serviceName);

                Assert.Throws <Microsoft.Azure.Management.ApiManagement.Models.ErrorResponseException>(() =>
                {
                    testBase.client.ApiManagementService.Get(
                        resourceGroupName: testBase.rgName,
                        serviceName: testBase.serviceName);
                });
            }
        }