/// <summary>
 /// The Put RouteTable operation creates/updates a route tablein the
 /// specified resource group.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.Network.IRouteTableOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group.
 /// </param>
 /// <param name='routeTableName'>
 /// Required. The name of the route table.
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters supplied to the create/update Route Table
 /// operation
 /// </param>
 /// <returns>
 /// Response for PUT RouteTables Api servive call
 /// </returns>
 public static RouteTablePutResponse BeginCreateOrUpdating(this IRouteTableOperations operations, string resourceGroupName, string routeTableName, RouteTable parameters)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IRouteTableOperations)s).BeginCreateOrUpdatingAsync(resourceGroupName, routeTableName, parameters);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
        public PSRouteTable ToPsRouteTable(RouteTable routeTable)
        {
            var psRouteTable = Mapper.Map<PSRouteTable>(routeTable);

            psRouteTable.Tag = TagsConversionHelper.CreateTagHashtable(routeTable.Tags);

            return psRouteTable;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the Subnet class.
 /// </summary>
 /// <param name="id">Resource ID.</param>
 /// <param name="addressPrefix">The address prefix for the
 /// subnet.</param>
 /// <param name="addressPrefixes">List of address prefixes for the
 /// subnet.</param>
 /// <param name="networkSecurityGroup">The reference of the
 /// NetworkSecurityGroup resource.</param>
 /// <param name="routeTable">The reference of the RouteTable
 /// resource.</param>
 /// <param name="natGateway">Nat gateway associated with this
 /// subnet.</param>
 /// <param name="serviceEndpoints">An array of service
 /// endpoints.</param>
 /// <param name="serviceEndpointPolicies">An array of service endpoint
 /// policies.</param>
 /// <param name="privateEndpoints">An array of references to private
 /// endpoints.</param>
 /// <param name="ipConfigurations">An array of references to the
 /// network interface IP configurations using subnet.</param>
 /// <param name="ipConfigurationProfiles">Array of IP configuration
 /// profiles which reference this subnet.</param>
 /// <param name="resourceNavigationLinks">An array of references to the
 /// external resources using subnet.</param>
 /// <param name="serviceAssociationLinks">An array of references to
 /// services injecting into this subnet.</param>
 /// <param name="delegations">An array of references to the delegations
 /// on the subnet.</param>
 /// <param name="purpose">A read-only string identifying the intention
 /// of use for this subnet based on delegations and other user-defined
 /// properties.</param>
 /// <param name="provisioningState">The provisioning state of the
 /// subnet resource. Possible values include: 'Succeeded', 'Updating',
 /// 'Deleting', 'Failed'</param>
 /// <param name="privateEndpointNetworkPolicies">Enable or Disable
 /// apply network policies on private end point in the subnet.</param>
 /// <param name="privateLinkServiceNetworkPolicies">Enable or Disable
 /// apply network policies on private link service in the
 /// subnet.</param>
 /// <param name="name">The name of the resource that is unique within a
 /// resource group. This name can be used to access the
 /// resource.</param>
 /// <param name="etag">A unique read-only string that changes whenever
 /// the resource is updated.</param>
 public Subnet(string id = default(string), string addressPrefix = default(string), IList <string> addressPrefixes = default(IList <string>), NetworkSecurityGroup networkSecurityGroup = default(NetworkSecurityGroup), RouteTable routeTable = default(RouteTable), SubResource natGateway = default(SubResource), IList <ServiceEndpointPropertiesFormat> serviceEndpoints = default(IList <ServiceEndpointPropertiesFormat>), IList <ServiceEndpointPolicy> serviceEndpointPolicies = default(IList <ServiceEndpointPolicy>), IList <PrivateEndpoint> privateEndpoints = default(IList <PrivateEndpoint>), IList <IPConfiguration> ipConfigurations = default(IList <IPConfiguration>), IList <IPConfigurationProfile> ipConfigurationProfiles = default(IList <IPConfigurationProfile>), IList <ResourceNavigationLink> resourceNavigationLinks = default(IList <ResourceNavigationLink>), IList <ServiceAssociationLink> serviceAssociationLinks = default(IList <ServiceAssociationLink>), IList <Delegation> delegations = default(IList <Delegation>), string purpose = default(string), string provisioningState = default(string), string privateEndpointNetworkPolicies = default(string), string privateLinkServiceNetworkPolicies = default(string), string name = default(string), string etag = default(string))
     : base(id)
 {
     AddressPrefix           = addressPrefix;
     AddressPrefixes         = addressPrefixes;
     NetworkSecurityGroup    = networkSecurityGroup;
     RouteTable              = routeTable;
     NatGateway              = natGateway;
     ServiceEndpoints        = serviceEndpoints;
     ServiceEndpointPolicies = serviceEndpointPolicies;
     PrivateEndpoints        = privateEndpoints;
     IpConfigurations        = ipConfigurations;
     IpConfigurationProfiles = ipConfigurationProfiles;
     ResourceNavigationLinks = resourceNavigationLinks;
     ServiceAssociationLinks = serviceAssociationLinks;
     Delegations             = delegations;
     Purpose           = purpose;
     ProvisioningState = provisioningState;
     PrivateEndpointNetworkPolicies    = privateEndpointNetworkPolicies;
     PrivateLinkServiceNetworkPolicies = privateLinkServiceNetworkPolicies;
     Name = name;
     Etag = etag;
     CustomInit();
 }
 /// <summary>
 /// The Put RouteTable operation creates/updates a route tablein the
 /// specified resource group.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.Network.IRouteTableOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group.
 /// </param>
 /// <param name='routeTableName'>
 /// Required. The name of the route table.
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters supplied to the create/update Route Table
 /// operation
 /// </param>
 /// <returns>
 /// Response for PUT RouteTables Api servive call
 /// </returns>
 public static Task<RouteTablePutResponse> BeginCreateOrUpdatingAsync(this IRouteTableOperations operations, string resourceGroupName, string routeTableName, RouteTable parameters)
 {
     return operations.BeginCreateOrUpdatingAsync(resourceGroupName, routeTableName, parameters, CancellationToken.None);
 }
Ejemplo n.º 5
0
        public void RouteTableApiTest()
        {
            var handler = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK };

            using (var context = UndoContext.Current)
            {
                context.Start();
                var resourcesClient = ResourcesManagementTestUtilities.GetResourceManagementClientWithHandler(handler);
                var networkResourceProviderClient =
                    NetworkManagementTestUtilities.GetNetworkResourceProviderClient(handler);

                var location = NetworkManagementTestUtilities.GetResourceLocation(resourcesClient, "Microsoft.Network/routeTables");

                string resourceGroupName = TestUtilities.GenerateName("csmrg");
                resourcesClient.ResourceGroups.CreateOrUpdate(
                    resourceGroupName,
                    new ResourceGroup { Location = location });

                string routeTableName = TestUtilities.GenerateName();
                string route1Name = TestUtilities.GenerateName();
                string route2Name = TestUtilities.GenerateName();

                var routeTable = new RouteTable() { Location = location, };

                // Add a route
                var route1 = new Route()
                                {
                                    AddressPrefix = "192.168.1.0/24",
                                    Name = route1Name,
                                    NextHopIpAddress = "23.108.1.1",
                                    NextHopType = RouteNextHopType.VirtualAppliance
                                };

                routeTable.Routes.Add(route1);

                // Put RouteTable
                var putRouteTableResponse =
                    networkResourceProviderClient.RouteTables.CreateOrUpdate(
                        resourceGroupName,
                        routeTableName,
                        routeTable);

                Assert.Equal(HttpStatusCode.OK, putRouteTableResponse.StatusCode);
                Assert.Equal("Succeeded", putRouteTableResponse.Status);

                // Get RouteTable
                var getRouteTableResponse = networkResourceProviderClient.RouteTables.Get(
                    resourceGroupName,
                    routeTableName);

                Assert.Equal(routeTableName, getRouteTableResponse.RouteTable.Name);
                Assert.Equal(1, getRouteTableResponse.RouteTable.Routes.Count);
                Assert.Equal(route1Name, getRouteTableResponse.RouteTable.Routes[0].Name);
                Assert.Equal("192.168.1.0/24", getRouteTableResponse.RouteTable.Routes[0].AddressPrefix);
                Assert.Equal("23.108.1.1", getRouteTableResponse.RouteTable.Routes[0].NextHopIpAddress);
                Assert.Equal(RouteNextHopType.VirtualAppliance, getRouteTableResponse.RouteTable.Routes[0].NextHopType);

                // Add another route
                var route2 = new Route()
                {
                    AddressPrefix = "10.0.1.0/24",
                    Name = route2Name,
                    NextHopType = RouteNextHopType.VnetLocal
                };
                getRouteTableResponse.RouteTable.Routes.Add(route2);

                networkResourceProviderClient.RouteTables.CreateOrUpdate(
                        resourceGroupName,
                        routeTableName,
                        getRouteTableResponse.RouteTable);

                getRouteTableResponse = networkResourceProviderClient.RouteTables.Get(
                    resourceGroupName,
                    routeTableName);
                Assert.Equal(routeTableName, getRouteTableResponse.RouteTable.Name);
                Assert.Equal(2, getRouteTableResponse.RouteTable.Routes.Count);
                Assert.Equal(route2Name, getRouteTableResponse.RouteTable.Routes[1].Name);
                Assert.Equal("10.0.1.0/24", getRouteTableResponse.RouteTable.Routes[1].AddressPrefix);
                Assert.True(string.IsNullOrEmpty(getRouteTableResponse.RouteTable.Routes[1].NextHopIpAddress));
                Assert.Equal(RouteNextHopType.VnetLocal, getRouteTableResponse.RouteTable.Routes[1].NextHopType);


                // Delete a route
                getRouteTableResponse.RouteTable.Routes.RemoveAt(0);

                networkResourceProviderClient.RouteTables.CreateOrUpdate(
                        resourceGroupName,
                        routeTableName,
                        getRouteTableResponse.RouteTable);

                getRouteTableResponse = networkResourceProviderClient.RouteTables.Get(
                    resourceGroupName,
                    routeTableName);
                Assert.Equal(routeTableName, getRouteTableResponse.RouteTable.Name);
                Assert.Equal(1, getRouteTableResponse.RouteTable.Routes.Count);
                Assert.Equal(route2Name, getRouteTableResponse.RouteTable.Routes[0].Name);
                Assert.Equal("10.0.1.0/24", getRouteTableResponse.RouteTable.Routes[0].AddressPrefix);
                Assert.True(string.IsNullOrEmpty(getRouteTableResponse.RouteTable.Routes[0].NextHopIpAddress));
                Assert.Equal(RouteNextHopType.VnetLocal, getRouteTableResponse.RouteTable.Routes[0].NextHopType);

                // Delete RouteTable
                var deleteRouteTableResponse = networkResourceProviderClient.RouteTables.Delete(
                    resourceGroupName,
                    routeTableName);
                Assert.Equal(HttpStatusCode.OK, deleteRouteTableResponse.StatusCode);

                // Verify delete
                var listRouteTableResponse = networkResourceProviderClient.RouteTables.List(resourceGroupName);

                Assert.Equal(HttpStatusCode.OK, listRouteTableResponse.StatusCode);
                Assert.Equal(0, listRouteTableResponse.RouteTables.Count);
            }
        }
Ejemplo n.º 6
0
        public void SubnetRouteTableTest()
        {
            var handler = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK };

            using (var context = UndoContext.Current)
            {
                context.Start();
                var resourcesClient = ResourcesManagementTestUtilities.GetResourceManagementClientWithHandler(handler);
                var networkResourceProviderClient =
                    NetworkManagementTestUtilities.GetNetworkResourceProviderClient(handler);

                var location = NetworkManagementTestUtilities.GetResourceLocation(resourcesClient, "Microsoft.Network/routeTables");

                string resourceGroupName = TestUtilities.GenerateName("csmrg");
                resourcesClient.ResourceGroups.CreateOrUpdate(
                    resourceGroupName,
                    new ResourceGroup { Location = location });

                string routeTableName = TestUtilities.GenerateName();
                string route1Name = TestUtilities.GenerateName();

                var routeTable = new RouteTable() { Location = location, };

                var route1 = new Route()
                {
                    AddressPrefix = "192.168.1.0/24",
                    Name = route1Name,
                    NextHopIpAddress = "23.108.1.1",
                    NextHopType = RouteNextHopType.VirtualAppliance
                };

                routeTable.Routes.Add(route1);

                // Put RouteTable
                var putRouteTableResponse =
                    networkResourceProviderClient.RouteTables.CreateOrUpdate(
                        resourceGroupName,
                        routeTableName,
                        routeTable);

                Assert.Equal(HttpStatusCode.OK, putRouteTableResponse.StatusCode);
                Assert.Equal("Succeeded", putRouteTableResponse.Status);

                // Get RouteTable
                var getRouteTableResponse = networkResourceProviderClient.RouteTables.Get(
                    resourceGroupName,
                    routeTableName);

                // Verify that the subnet reference is null
                Assert.False(getRouteTableResponse.RouteTable.Subnets.Any());

                // Create Vnet with subnet and add a route table
                string vnetName = TestUtilities.GenerateName();
                string subnetName = TestUtilities.GenerateName();

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

                    AddressSpace = new AddressSpace()
                    {
                        AddressPrefixes = new List<string>()
                    {
                        "10.0.0.0/16",
                    }
                    },
                    DhcpOptions = new DhcpOptions()
                    {
                        DnsServers = new List<string>()
                    {
                        "10.1.1.1",
                        "10.1.2.4"
                    }
                    },
                    Subnets = new List<Subnet>()
                    {
                        new Subnet()
                        {
                            Name = subnetName,
                            AddressPrefix = "10.0.0.0/24",
                            RouteTable = new ResourceId()
                                {
                                    Id = getRouteTableResponse.RouteTable.Id,
                                }
                        }
                    }
                };

                var putVnetResponse = networkResourceProviderClient.VirtualNetworks.CreateOrUpdate(resourceGroupName, vnetName, vnet);
                Assert.Equal(HttpStatusCode.OK, putVnetResponse.StatusCode);

                var getSubnetResponse = networkResourceProviderClient.Subnets.Get(resourceGroupName, vnetName, subnetName);
                Assert.Equal(getSubnetResponse.Subnet.RouteTable.Id, getRouteTableResponse.RouteTable.Id);

                // Get RouteTable
                getRouteTableResponse = networkResourceProviderClient.RouteTables.Get(
                    resourceGroupName,
                    routeTableName);
                Assert.Equal(1, getRouteTableResponse.RouteTable.Subnets.Count);
                Assert.Equal(getSubnetResponse.Subnet.Id, getRouteTableResponse.RouteTable.Subnets[0].Id);
            }
        }
Ejemplo n.º 7
0
        public void EmptyRouteTableTest()
        {
            var handler = new RecordedDelegatingHandler {StatusCodeToReturn = HttpStatusCode.OK};

            using (var context = UndoContext.Current)
            {
                context.Start();
                var resourcesClient = ResourcesManagementTestUtilities.GetResourceManagementClientWithHandler(handler);
                var networkResourceProviderClient =
                    NetworkManagementTestUtilities.GetNetworkResourceProviderClient(handler);

                var location = NetworkManagementTestUtilities.GetResourceLocation(resourcesClient, "Microsoft.Network/routeTables");
                
                string resourceGroupName = TestUtilities.GenerateName("csmrg");
                resourcesClient.ResourceGroups.CreateOrUpdate(
                    resourceGroupName,
                    new ResourceGroup { Location = location });

                string routeTableName = TestUtilities.GenerateName();

                var routeTable = new RouteTable() { Location = location, };

                // Put RouteTable
                var putRouteTableResponse =
                    networkResourceProviderClient.RouteTables.CreateOrUpdate(
                        resourceGroupName,
                        routeTableName,
                        routeTable);

                Assert.Equal(HttpStatusCode.OK, putRouteTableResponse.StatusCode);
                Assert.Equal("Succeeded", putRouteTableResponse.Status);

                // Get RouteTable
                var getRouteTableResponse = networkResourceProviderClient.RouteTables.Get(
                    resourceGroupName,
                    routeTableName);

                Assert.Equal(routeTableName, getRouteTableResponse.RouteTable.Name);
                Assert.False(getRouteTableResponse.RouteTable.Routes.Any());

                // List RouteTable
                var listRouteTableResponse = networkResourceProviderClient.RouteTables.List(resourceGroupName);

                Assert.Equal(HttpStatusCode.OK, listRouteTableResponse.StatusCode);
                Assert.Equal(1, listRouteTableResponse.RouteTables.Count);
                Assert.Equal(getRouteTableResponse.RouteTable.Name, listRouteTableResponse.RouteTables[0].Name);
                Assert.Equal(getRouteTableResponse.RouteTable.Id, listRouteTableResponse.RouteTables[0].Id);

                // Delete RouteTable
                var deleteRouteTableResponse = networkResourceProviderClient.RouteTables.Delete(
                    resourceGroupName,
                    routeTableName);
                Assert.Equal(HttpStatusCode.OK, deleteRouteTableResponse.StatusCode);

                // Verify delete
                listRouteTableResponse = networkResourceProviderClient.RouteTables.List(resourceGroupName);

                Assert.Equal(HttpStatusCode.OK, listRouteTableResponse.StatusCode);
                Assert.Equal(0, listRouteTableResponse.RouteTables.Count);
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the Subnet class.
 /// </summary>
 public Subnet(string id = default(string), string addressPrefix = default(string), NetworkSecurityGroup networkSecurityGroup = default(NetworkSecurityGroup), RouteTable routeTable = default(RouteTable), IList <IPConfiguration> ipConfigurations = default(IList <IPConfiguration>), IList <ResourceNavigationLink> resourceNavigationLinks = default(IList <ResourceNavigationLink>), string provisioningState = default(string), string name = default(string), string etag = default(string))
     : base(id)
 {
     AddressPrefix           = addressPrefix;
     NetworkSecurityGroup    = networkSecurityGroup;
     RouteTable              = routeTable;
     IpConfigurations        = ipConfigurations;
     ResourceNavigationLinks = resourceNavigationLinks;
     ProvisioningState       = provisioningState;
     Name = name;
     Etag = etag;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the Subnet class.
 /// </summary>
 public Subnet(string name = default(string), string etag = default(string), string addressPrefix = default(string), NetworkSecurityGroup networkSecurityGroup = default(NetworkSecurityGroup), RouteTable routeTable = default(RouteTable), IList <IPConfiguration> ipConfigurations = default(IList <IPConfiguration>), string provisioningState = default(string))
 {
     Name                 = name;
     Etag                 = etag;
     AddressPrefix        = addressPrefix;
     NetworkSecurityGroup = networkSecurityGroup;
     RouteTable           = routeTable;
     IpConfigurations     = ipConfigurations;
     ProvisioningState    = provisioningState;
 }