/// <summary>
        /// Constructs an object used to create a <see cref="NetworkInterface"/>.
        /// </summary>
        /// <param name="ip"> The public IP address of the <see cref="NetworkInterface"/>. </param>
        /// <param name="subnetId"> The resource identifier of the subnet attached to this <see cref="NetworkInterface"/>. </param>
        /// <param name="location"> The <see cref="LocationData"/> that will contain the <see cref="NetworkInterface"/>. </param>
        /// <returns>An object used to create a <see cref="NetworkInterface"/>. </returns>
        public ArmBuilder <NetworkInterface, NetworkInterfaceData> Construct(string subnetId, PublicIPAddressData ip = default, LocationData location = null)
        {
            var parent = GetParentResource <ResourceGroup, ResourceGroupOperations>();
            var nic    = new Azure.ResourceManager.Network.Models.NetworkInterface()
            {
                Location         = location ?? parent.Data.Location,
                IpConfigurations = new List <NetworkInterfaceIPConfiguration>()
                {
                    new NetworkInterfaceIPConfiguration()
                    {
                        Name    = "Primary",
                        Primary = true,
                        Subnet  = new Azure.ResourceManager.Network.Models.Subnet()
                        {
                            Id = subnetId
                        },
                        PrivateIPAllocationMethod = IPAllocationMethod.Dynamic,
                    }
                }
            };

            if (ip != null)
            {
                nic.IpConfigurations[0].PublicIPAddress = new PublicIPAddress()
                {
                    Id = ip.Id
                }
            }
            ;

            return(new ArmBuilder <NetworkInterface, NetworkInterfaceData>(this, new NetworkInterfaceData(nic)));
        }
Beispiel #2
0
        public ArmBuilder <NetworkInterface, NetworkInterfaceData> Construct(PublicIPAddressData ip, string subnetId, Location location = null)
        {
            var nic = new Azure.ResourceManager.Network.Models.NetworkInterface()
            {
                Location         = location ?? DefaultLocation,
                IpConfigurations = new List <NetworkInterfaceIPConfiguration>()
                {
                    new NetworkInterfaceIPConfiguration()
                    {
                        Name    = "Primary",
                        Primary = true,
                        Subnet  = new Azure.ResourceManager.Network.Models.Subnet()
                        {
                            Id = subnetId
                        },
                        PrivateIPAllocationMethod = IPAllocationMethod.Dynamic,
                        PublicIPAddress           = new PublicIPAddress()
                        {
                            Id = ip.Id
                        }
                    }
                }
            };

            return(new ArmBuilder <NetworkInterface, NetworkInterfaceData>(this, new NetworkInterfaceData(nic)));
        }