public async Task <Config.Subnet> CreateSubnetAsync( Guid subscriptionId, string location, string resourceGroupName, string vnetName, string subnetName, string subnetAddressRange, string environmentName) { await RegisterProvider(subscriptionId, "Microsoft.Network"); var accessToken = await GetAccessToken(); var token = new TokenCredentials(accessToken); var networkClient = new NetworkManagementClient(token) { SubscriptionId = subscriptionId.ToString() }; var newSubnet = new Subnet(name: subnetName, addressPrefix: subnetAddressRange); var subnetResult = await networkClient.Subnets.CreateOrUpdateAsync(resourceGroupName, vnetName, subnetName, newSubnet); var subnet = await GetSubnetAsync(subscriptionId, location, resourceGroupName, vnetName, subnetName); subnet.ExistingResource = false; return(subnet); }
/// <summary> /// The Put Subnet operation creates/updates a subnet in thespecified /// virtual network /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.Azure.Management.Network.ISubnetOperations. /// </param> /// <param name='resourceGroupName'> /// Required. The name of the resource group. /// </param> /// <param name='virtualNetworkName'> /// Required. The name of the virtual network. /// </param> /// <param name='subnetName'> /// Required. The name of the subnet. /// </param> /// <param name='subnetParameters'> /// Required. Parameters supplied to the create/update Subnet operation /// </param> /// <returns> /// Response for PutSubnet Api service call /// </returns> public static SubnetPutResponse BeginCreateOrUpdating(this ISubnetOperations operations, string resourceGroupName, string virtualNetworkName, string subnetName, Subnet subnetParameters) { return Task.Factory.StartNew((object s) => { return ((ISubnetOperations)s).BeginCreateOrUpdatingAsync(resourceGroupName, virtualNetworkName, subnetName, subnetParameters); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); }
private Config.Subnet ParseSubnet(VirtualNetwork vnet, Subnet subnet) { if (vnet == null || subnet == null) { return(null); } return(new Config.Subnet { VNetAddressPrefixes = string.Join(',', vnet.AddressSpace.AddressPrefixes), AddressPrefix = subnet.AddressPrefix, Location = vnet.Location, ResourceId = subnet.Id, ExistingResource = true, }); }
protected NetworkInterfaceGetResponse CreateNIC(string rgName, Subnet subnet, PublicIpAddress publicIPaddress, string nicname = null) { // Create Nic nicname = nicname ?? TestUtilities.GenerateName(); string ipConfigName = TestUtilities.GenerateName(); var nicParameters = new NetworkInterface() { Location = m_location, Name = nicname, Tags = new Dictionary<string, string>() { { "key" ,"value" } }, IpConfigurations = new List<NetworkInterfaceIpConfiguration>() { new NetworkInterfaceIpConfiguration() { Name = ipConfigName, PrivateIpAllocationMethod = IpAllocationMethod.Dynamic, Subnet = subnet, } } }; if (publicIPaddress != null) { nicParameters.IpConfigurations[0].PublicIpAddress = new ResourceId { Id = publicIPaddress.Id }; } var putNicResponse = m_NrpClient.NetworkInterfaces.CreateOrUpdate(rgName, nicname, nicParameters); var getNicResponse = m_NrpClient.NetworkInterfaces.Get(rgName, nicname); return getNicResponse; }
private void Init() { vnetName = "azsmnet_vnetName"; subnetName = "azsmnet_subnetName"; subnet = CreateSubnet(); }
private ApplicationGateway CreateApplicationGateway(string location, Subnet subnet, string resourceGroupName, string subscriptionId) { var appGwName = TestUtilities.GenerateName(); var gatewayIPConfigName = TestUtilities.GenerateName(); var frontendIPConfigName = TestUtilities.GenerateName(); var frontendPortName = TestUtilities.GenerateName(); var backendAddressPoolName = TestUtilities.GenerateName(); var backendHttpSettingsName = TestUtilities.GenerateName(); var requestRoutingRuleName = TestUtilities.GenerateName(); var httpListenerName = TestUtilities.GenerateName(); var appGw = new ApplicationGateway() { Location = location, Name = appGwName, Sku = new ApplicationGatewaySku() { Name = ApplicationGatewaySkuName.StandardSmall, Tier = ApplicationGatewayTier.Standard, Capacity = 2 }, GatewayIPConfigurations = new List<ApplicationGatewayIPConfiguration>() { new ApplicationGatewayIPConfiguration() { Name = gatewayIPConfigName, Subnet = new ResourceId() { Id = subnet.Id } } }, FrontendIPConfigurations = new List<ApplicationGatewayFrontendIPConfiguration>() { new ApplicationGatewayFrontendIPConfiguration() { Name = frontendIPConfigName, PrivateIPAllocationMethod = IpAllocationMethod.Dynamic, Subnet = new ResourceId() { Id = subnet.Id } } }, FrontendPorts = new List<ApplicationGatewayFrontendPort> { new ApplicationGatewayFrontendPort() { Name = frontendPortName, Port = 80 } }, BackendAddressPools = new List<ApplicationGatewayBackendAddressPool> { new ApplicationGatewayBackendAddressPool() { Name = backendAddressPoolName, BackendAddresses = new List<ApplicationGatewayBackendAddress>() { new ApplicationGatewayBackendAddress() { IpAddress = "104.42.6.202" }, new ApplicationGatewayBackendAddress() { IpAddress = "23.99.1.115" } } } }, BackendHttpSettingsCollection = new List<ApplicationGatewayBackendHttpSettings> { new ApplicationGatewayBackendHttpSettings() { Name = backendHttpSettingsName, Port = 80, Protocol = ApplicationGatewayProtocol.Http, CookieBasedAffinity = ApplicationGatewayCookieBasedAffinity.Disabled } }, HttpListeners = new List<ApplicationGatewayHttpListener> { new ApplicationGatewayHttpListener() { Name = httpListenerName, FrontendPort = new ResourceId() { Id = GetChildAppGwResourceId(subscriptionId, resourceGroupName, appGwName, "frontendPorts", frontendPortName) }, FrontendIPConfiguration = new ResourceId() { Id = GetChildAppGwResourceId(subscriptionId, resourceGroupName, appGwName, "frontendIPConfigurations", frontendIPConfigName) }, SslCertificate = null, Protocol = ApplicationGatewayProtocol.Http } }, RequestRoutingRules = new List<ApplicationGatewayRequestRoutingRule>() { new ApplicationGatewayRequestRoutingRule() { Name = requestRoutingRuleName, RuleType = ApplicationGatewayRequestRoutingRuleType.Basic, HttpListener = new ResourceId() { Id = GetChildAppGwResourceId(subscriptionId, resourceGroupName, appGwName, "httpListeners", httpListenerName) }, BackendAddressPool = new ResourceId() { Id = GetChildAppGwResourceId(subscriptionId, resourceGroupName, appGwName, "backendAddressPools", backendAddressPoolName) }, BackendHttpSettings = new ResourceId() { Id = GetChildAppGwResourceId(subscriptionId, resourceGroupName, appGwName, "backendHttpSettingsCollection", backendHttpSettingsName) } } } }; return appGw; }
public void SubnetApiTest() { 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/virtualNetworks"); string resourceGroupName = TestUtilities.GenerateName("csmrg"); resourcesClient.ResourceGroups.CreateOrUpdate(resourceGroupName, new ResourceGroup { Location = location }); string vnetName = TestUtilities.GenerateName(); string subnet1Name = TestUtilities.GenerateName(); string subnet2Name = 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 = subnet1Name, AddressPrefix = "10.0.0.0/24", } } }; var putVnetResponse = networkResourceProviderClient.VirtualNetworks.CreateOrUpdate(resourceGroupName,vnetName, vnet); Assert.Equal(HttpStatusCode.OK, putVnetResponse.StatusCode); // Create a Subnet // Populate paramters for a Subnet var subnet = new Subnet() { Name = subnet2Name, AddressPrefix = "10.0.1.0/24", }; #region Verification var putSubnetResponse = networkResourceProviderClient.Subnets.CreateOrUpdate(resourceGroupName, vnetName, subnet2Name, subnet); Assert.Equal(HttpStatusCode.OK, putSubnetResponse.StatusCode); var getVnetResponse = networkResourceProviderClient.VirtualNetworks.Get(resourceGroupName, vnetName); Assert.Equal(HttpStatusCode.OK, getVnetResponse.StatusCode); Assert.Equal(2, getVnetResponse.VirtualNetwork.Subnets.Count); var getSubnetResponse = networkResourceProviderClient.Subnets.Get(resourceGroupName, vnetName, subnet2Name); Assert.Equal(HttpStatusCode.OK, getSubnetResponse.StatusCode); // Verify the getSubnetResponse Assert.True(AreSubnetsEqual(getVnetResponse.VirtualNetwork.Subnets[1], getSubnetResponse.Subnet)); var getSubnetListResponse = networkResourceProviderClient.Subnets.List(resourceGroupName, vnetName); Assert.Equal(HttpStatusCode.OK, getSubnetListResponse.StatusCode); // Verify ListSubnets Assert.True(AreSubnetsEqual(getVnetResponse.VirtualNetwork.Subnets, getSubnetListResponse.Subnets)); // Delete the subnet "subnet1" var deleteSubnetResponse = networkResourceProviderClient.Subnets.Delete(resourceGroupName, vnetName, subnet2Name); Assert.Equal(HttpStatusCode.OK, deleteSubnetResponse.StatusCode); // Verify that the deletion was successful getSubnetListResponse = networkResourceProviderClient.Subnets.List(resourceGroupName, vnetName); Assert.Equal(HttpStatusCode.OK, getSubnetListResponse.StatusCode); Assert.Equal(1, getSubnetListResponse.Subnets.Count); Assert.Equal(subnet1Name, getSubnetListResponse.Subnets[0].Name); #endregion } }
/// <summary> /// Initializes a new instance of the NetworkInterfaceIPConfiguration /// class. /// </summary> /// <param name="id">Resource ID.</param> /// <param name="virtualNetworkTaps">The reference to Virtual Network /// Taps.</param> /// <param name="applicationGatewayBackendAddressPools">The reference /// to ApplicationGatewayBackendAddressPool resource.</param> /// <param name="loadBalancerBackendAddressPools">The reference to /// LoadBalancerBackendAddressPool resource.</param> /// <param name="loadBalancerInboundNatRules">A list of references of /// LoadBalancerInboundNatRules.</param> /// <param name="privateIPAddress">Private IP address of the IP /// configuration.</param> /// <param name="privateIPAllocationMethod">The private IP address /// allocation method. Possible values include: 'Static', /// 'Dynamic'</param> /// <param name="privateIPAddressVersion">Whether the specific IP /// configuration is IPv4 or IPv6. Default is IPv4. Possible values /// include: 'IPv4', 'IPv6'</param> /// <param name="subnet">Subnet bound to the IP configuration.</param> /// <param name="primary">Whether this is a primary customer address on /// the network interface.</param> /// <param name="publicIPAddress">Public IP address bound to the IP /// configuration.</param> /// <param name="applicationSecurityGroups">Application security groups /// in which the IP configuration is included.</param> /// <param name="provisioningState">The provisioning state of the /// network interface IP configuration. Possible values include: /// 'Succeeded', 'Updating', 'Deleting', 'Failed'</param> /// <param name="privateLinkConnectionProperties">PrivateLinkConnection /// properties for the network interface.</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 NetworkInterfaceIPConfiguration(string id = default(string), IList <VirtualNetworkTap> virtualNetworkTaps = default(IList <VirtualNetworkTap>), IList <ApplicationGatewayBackendAddressPool> applicationGatewayBackendAddressPools = default(IList <ApplicationGatewayBackendAddressPool>), IList <BackendAddressPool> loadBalancerBackendAddressPools = default(IList <BackendAddressPool>), IList <InboundNatRule> loadBalancerInboundNatRules = default(IList <InboundNatRule>), string privateIPAddress = default(string), string privateIPAllocationMethod = default(string), string privateIPAddressVersion = default(string), Subnet subnet = default(Subnet), bool?primary = default(bool?), PublicIPAddress publicIPAddress = default(PublicIPAddress), IList <ApplicationSecurityGroup> applicationSecurityGroups = default(IList <ApplicationSecurityGroup>), string provisioningState = default(string), NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties privateLinkConnectionProperties = default(NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties), string name = default(string), string etag = default(string)) : base(id) { VirtualNetworkTaps = virtualNetworkTaps; ApplicationGatewayBackendAddressPools = applicationGatewayBackendAddressPools; LoadBalancerBackendAddressPools = loadBalancerBackendAddressPools; LoadBalancerInboundNatRules = loadBalancerInboundNatRules; PrivateIPAddress = privateIPAddress; PrivateIPAllocationMethod = privateIPAllocationMethod; PrivateIPAddressVersion = privateIPAddressVersion; Subnet = subnet; Primary = primary; PublicIPAddress = publicIPAddress; ApplicationSecurityGroups = applicationSecurityGroups; ProvisioningState = provisioningState; PrivateLinkConnectionProperties = privateLinkConnectionProperties; Name = name; Etag = etag; CustomInit(); }
/// <summary> /// Initializes a new instance of the NetworkInterfaceIPConfiguration /// class. /// </summary> public NetworkInterfaceIPConfiguration(string id = default(string), IList<ApplicationGatewayBackendAddressPool> applicationGatewayBackendAddressPools = default(IList<ApplicationGatewayBackendAddressPool>), IList<BackendAddressPool> loadBalancerBackendAddressPools = default(IList<BackendAddressPool>), IList<InboundNatRule> loadBalancerInboundNatRules = default(IList<InboundNatRule>), string privateIPAddress = default(string), string privateIPAllocationMethod = default(string), string privateIPAddressVersion = default(string), Subnet subnet = default(Subnet), bool? primary = default(bool?), PublicIPAddress publicIPAddress = default(PublicIPAddress), string provisioningState = default(string), string name = default(string), string etag = default(string)) : base(id) { ApplicationGatewayBackendAddressPools = applicationGatewayBackendAddressPools; LoadBalancerBackendAddressPools = loadBalancerBackendAddressPools; LoadBalancerInboundNatRules = loadBalancerInboundNatRules; PrivateIPAddress = privateIPAddress; PrivateIPAllocationMethod = privateIPAllocationMethod; PrivateIPAddressVersion = privateIPAddressVersion; Subnet = subnet; Primary = primary; PublicIPAddress = publicIPAddress; ProvisioningState = provisioningState; Name = name; Etag = etag; }
/// <summary> /// Initializes a new instance of the PrivateLinkServiceIpConfiguration /// class. /// </summary> /// <param name="id">Resource ID.</param> /// <param name="privateIPAddress">The private IP address of the IP /// configuration.</param> /// <param name="privateIPAllocationMethod">The private IP address /// allocation method. Possible values include: 'Static', /// 'Dynamic'</param> /// <param name="subnet">The reference to the subnet resource.</param> /// <param name="primary">Whether the ip configuration is primary or /// not.</param> /// <param name="provisioningState">The provisioning state of the /// private link service IP configuration resource. Possible values /// include: 'Succeeded', 'Updating', 'Deleting', 'Failed'</param> /// <param name="privateIPAddressVersion">Whether the specific IP /// configuration is IPv4 or IPv6. Default is IPv4. Possible values /// include: 'IPv4', 'IPv6'</param> /// <param name="name">The name of private link service ip /// configuration.</param> /// <param name="etag">A unique read-only string that changes whenever /// the resource is updated.</param> /// <param name="type">The resource type.</param> public PrivateLinkServiceIpConfiguration(string id = default(string), string privateIPAddress = default(string), string privateIPAllocationMethod = default(string), Subnet subnet = default(Subnet), bool?primary = default(bool?), string provisioningState = default(string), string privateIPAddressVersion = default(string), string name = default(string), string etag = default(string), string type = default(string)) : base(id) { PrivateIPAddress = privateIPAddress; PrivateIPAllocationMethod = privateIPAllocationMethod; Subnet = subnet; Primary = primary; ProvisioningState = provisioningState; PrivateIPAddressVersion = privateIPAddressVersion; Name = name; Etag = etag; Type = type; CustomInit(); }
/// <summary> /// The Put Subnet operation creates/updates a subnet in thespecified /// virtual network /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.Azure.Management.Network.ISubnetOperations. /// </param> /// <param name='resourceGroupName'> /// Required. The name of the resource group. /// </param> /// <param name='virtualNetworkName'> /// Required. The name of the virtual network. /// </param> /// <param name='subnetName'> /// Required. The name of the subnet. /// </param> /// <param name='subnetParameters'> /// Required. Parameters supplied to the create/update Subnet operation /// </param> /// <returns> /// Response for PutSubnet Api service call /// </returns> public static Task<SubnetPutResponse> BeginCreateOrUpdatingAsync(this ISubnetOperations operations, string resourceGroupName, string virtualNetworkName, string subnetName, Subnet subnetParameters) { return operations.BeginCreateOrUpdatingAsync(resourceGroupName, virtualNetworkName, subnetName, subnetParameters, CancellationToken.None); }
/// <summary> /// Initializes a new instance of the IPConfiguration class. /// </summary> /// <param name="id">Resource ID.</param> /// <param name="privateIPAddress">The private IP address of the IP /// configuration.</param> /// <param name="privateIPAllocationMethod">The private IP address /// allocation method. Possible values include: 'Static', /// 'Dynamic'</param> /// <param name="subnet">The reference of the subnet resource.</param> /// <param name="publicIPAddress">The reference of the public IP /// resource.</param> /// <param name="provisioningState">Gets the provisioning state of the /// public IP resource. Possible values are: 'Updating', 'Deleting', /// and 'Failed'.</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 IPConfiguration(string id = default(string), string privateIPAddress = default(string), string privateIPAllocationMethod = default(string), Subnet subnet = default(Subnet), PublicIPAddress publicIPAddress = default(PublicIPAddress), string provisioningState = default(string), string name = default(string), string etag = default(string)) : base(id) { PrivateIPAddress = privateIPAddress; PrivateIPAllocationMethod = privateIPAllocationMethod; Subnet = subnet; PublicIPAddress = publicIPAddress; ProvisioningState = provisioningState; Name = name; Etag = etag; CustomInit(); }
/// <summary> /// Initializes a new instance of the PrivateEndpoint class. /// </summary> /// <param name="id">Resource ID.</param> /// <param name="name">Resource name.</param> /// <param name="type">Resource type.</param> /// <param name="location">Resource location.</param> /// <param name="tags">Resource tags.</param> /// <param name="subnet">The ID of the subnet from which the private IP /// will be allocated.</param> /// <param name="networkInterfaces">Gets an array of references to the /// network interfaces created for this private endpoint.</param> /// <param name="provisioningState">The provisioning state of the /// private endpoint. Possible values are: 'Updating', 'Deleting', and /// 'Failed'.</param> /// <param name="privateLinkServiceConnections">A grouping of /// information about the connection to the remote resource.</param> /// <param name="manualPrivateLinkServiceConnections">A grouping of /// information about the connection to the remote resource. Used when /// the network admin does not have access to approve connections to /// the remote resource.</param> /// <param name="etag">Gets a unique read-only string that changes /// whenever the resource is updated.</param> public PrivateEndpoint(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary <string, string> tags = default(IDictionary <string, string>), Subnet subnet = default(Subnet), IList <NetworkInterface> networkInterfaces = default(IList <NetworkInterface>), string provisioningState = default(string), IList <PrivateLinkServiceConnection> privateLinkServiceConnections = default(IList <PrivateLinkServiceConnection>), IList <PrivateLinkServiceConnection> manualPrivateLinkServiceConnections = default(IList <PrivateLinkServiceConnection>), string etag = default(string)) : base(id, name, type, location, tags) { Subnet = subnet; NetworkInterfaces = networkInterfaces; ProvisioningState = provisioningState; PrivateLinkServiceConnections = privateLinkServiceConnections; ManualPrivateLinkServiceConnections = manualPrivateLinkServiceConnections; Etag = etag; CustomInit(); }
/// <summary> /// Initializes a new instance of the FrontendIPConfiguration class. /// </summary> /// <param name="id">Resource ID.</param> /// <param name="inboundNatRules">Read only. Inbound rules URIs that /// use this frontend IP.</param> /// <param name="inboundNatPools">Read only. Inbound pools URIs that /// use this frontend IP.</param> /// <param name="outboundRules">Read only. Outbound rules URIs that use /// this frontend IP.</param> /// <param name="loadBalancingRules">Gets load balancing rules URIs /// that use this frontend IP.</param> /// <param name="privateIPAddress">The private IP address of the IP /// configuration.</param> /// <param name="privateIPAllocationMethod">The Private IP allocation /// method. Possible values include: 'Static', 'Dynamic'</param> /// <param name="privateIPAddressVersion">It represents whether the /// specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. /// Possible values include: 'IPv4', 'IPv6'</param> /// <param name="subnet">The reference of the subnet resource.</param> /// <param name="publicIPAddress">The reference of the Public IP /// resource.</param> /// <param name="publicIPPrefix">The reference of the Public IP Prefix /// resource.</param> /// <param name="provisioningState">Gets the provisioning state of the /// public IP resource. Possible values are: 'Updating', 'Deleting', /// and 'Failed'.</param> /// <param name="name">The name of the resource that is unique within /// the set of frontend IP configurations used by the load balancer. /// 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> /// <param name="type">Type of the resource.</param> /// <param name="zones">A list of availability zones denoting the IP /// allocated for the resource needs to come from.</param> public FrontendIPConfiguration(string id = default(string), IList <SubResource> inboundNatRules = default(IList <SubResource>), IList <SubResource> inboundNatPools = default(IList <SubResource>), IList <SubResource> outboundRules = default(IList <SubResource>), IList <SubResource> loadBalancingRules = default(IList <SubResource>), string privateIPAddress = default(string), string privateIPAllocationMethod = default(string), string privateIPAddressVersion = default(string), Subnet subnet = default(Subnet), PublicIPAddress publicIPAddress = default(PublicIPAddress), SubResource publicIPPrefix = default(SubResource), string provisioningState = default(string), string name = default(string), string etag = default(string), string type = default(string), IList <string> zones = default(IList <string>)) : base(id) { InboundNatRules = inboundNatRules; InboundNatPools = inboundNatPools; OutboundRules = outboundRules; LoadBalancingRules = loadBalancingRules; PrivateIPAddress = privateIPAddress; PrivateIPAllocationMethod = privateIPAllocationMethod; PrivateIPAddressVersion = privateIPAddressVersion; Subnet = subnet; PublicIPAddress = publicIPAddress; PublicIPPrefix = publicIPPrefix; ProvisioningState = provisioningState; Name = name; Etag = etag; Type = type; Zones = zones; CustomInit(); }
private bool AreSubnetsEqual(Subnet subnet1, Subnet subnet2) { return subnet1.Id == subnet2.Id && subnet1.Etag == subnet2.Etag && subnet1.ProvisioningState == subnet2.ProvisioningState && subnet1.Name == subnet2.Name && subnet1.AddressPrefix == subnet2.AddressPrefix; }
/// <summary> /// Initializes a new instance of the FrontendIPConfiguration class. /// </summary> public FrontendIPConfiguration(string id = default(string), IList <SubResource> inboundNatRules = default(IList <SubResource>), IList <SubResource> inboundNatPools = default(IList <SubResource>), IList <SubResource> outboundNatRules = default(IList <SubResource>), IList <SubResource> loadBalancingRules = default(IList <SubResource>), string privateIPAddress = default(string), string privateIPAllocationMethod = default(string), Subnet subnet = default(Subnet), PublicIPAddress publicIPAddress = default(PublicIPAddress), string provisioningState = default(string), string name = default(string), string etag = default(string)) : base(id) { InboundNatRules = inboundNatRules; InboundNatPools = inboundNatPools; OutboundNatRules = outboundNatRules; LoadBalancingRules = loadBalancingRules; PrivateIPAddress = privateIPAddress; PrivateIPAllocationMethod = privateIPAllocationMethod; Subnet = subnet; PublicIPAddress = publicIPAddress; ProvisioningState = provisioningState; Name = name; Etag = etag; }
/// <summary> /// Create Virtual Network /// </summary> /// <param name="credentials">Credentials to authorize application</param> /// <param name="subscriptionId">SubscriptionID that identifies subscription to create resoruce in</param> /// <param name="resourceGroup">Name of resource group</param> /// <param name="location">Location for resource</param> /// <param name="vNetName">Internal name used to identify Virtual Network within your subscription</param> /// <param name="vNetAddressPrefix">IP Address range for Virtual Network</param> /// <param name="subnets">List of Subnets to be provisioned inside the Virtual Network</param> /// <returns>Awaitable task</returns> private static Task<VirtualNetwork> CreateVirtualNetworkAsync(TokenCredentials credentials, string subscriptionId, string resourceGroup, string location, string vNetName, string vNetAddressPrefix, Subnet[] subnets) { Console.WriteLine("Creating Virtual Network"); var networkClient = new NetworkManagementClient(credentials) { SubscriptionId = subscriptionId }; var createVNetTask = networkClient.VirtualNetworks.CreateOrUpdateAsync(resourceGroup, vNetName, new VirtualNetwork { Location = location, AddressSpace = new AddressSpace(new[] { vNetAddressPrefix }), Subnets = subnets }); return createVNetTask; }
/// <summary> /// Create Virtual Network Interface Card, NIC /// </summary> /// <param name="credentials">Credentials to authorize application</param> /// <param name="subscriptionId">SubscriptionID that identifies subscription to create resoruce in</param> /// <param name="resourceGroup">Name of resource group</param> /// <param name="location">Location for resource</param> /// <param name="nicName">Internal name for NIC</param> /// <param name="nicIPConfigName">Internal name for NIC Configuration. Sample only provides one configuration, but could be extended to provide more</param> /// <param name="pip">Public IP Address to be assigned to NIC</param> /// <param name="subnet">Subnet to use for current configuration</param> /// <returns>Awaitable task</returns> private static Task<NetworkInterface> CreateNetworkInterfaceAsync(TokenCredentials credentials, string subscriptionId, string resourceGroup, string location, string nicName, string nicIPConfigName, PublicIPAddress pip, Subnet subnet) { Console.WriteLine("Creating Network Interface"); var networkClient = new NetworkManagementClient(credentials) { SubscriptionId = subscriptionId }; var createNicTask = networkClient.NetworkInterfaces.CreateOrUpdateAsync(resourceGroup, nicName, new NetworkInterface() { Location = location, IpConfigurations = new[] { new NetworkInterfaceIPConfiguration { Name = nicIPConfigName, PrivateIPAllocationMethod = "Dynamic", PublicIPAddress = pip, Subnet = subnet } } }); return createNicTask; }