Esempio n. 1
0
        private static AzureNic CreateNic(AzureResourceGroup resourceGroup, AzureSubnet subnet, int i)
        {
            // Create IP Address
            Console.WriteLine("--------Start create IP Address--------");
            var ipAddress = resourceGroup.ConstructIPAddress();

            ipAddress = resourceGroup.IpAddresses().CreateOrUpdatePublicIpAddress(String.Format("{0}_{1}_ip", vmName, i), ipAddress);

            // Create Network Interface
            Console.WriteLine("--------Start create Network Interface--------");
            var nic = resourceGroup.ConstructNic(ipAddress, subnet.Id);

            nic = resourceGroup.Nics().CreateOrUpdateNic(String.Format("{0}_{1}_nic", vmName, i), nic);
            return(nic);
        }
Esempio n. 2
0
        private static void SetupVmHost(out AzureResourceGroup resourceGroup, out AzureAvailabilitySet aset, out AzureSubnet subnet)
        {
            AzureClient client       = new AzureClient();
            var         subscription = client.Subscriptions[subscriptionId];

            // Create Resource Group
            Console.WriteLine("--------Start create group--------");
            resourceGroup = subscription.ResourceGroups.CreateOrUpdate(rgName, loc);

            // Create AvailabilitySet
            Console.WriteLine("--------Start create AvailabilitySet--------");
            aset = resourceGroup.ConstructAvailabilitySet("Aligned");
            aset = resourceGroup.AvailabilitySets().CreateOrUpdateAvailabilityset(vmName + "_aSet", aset);

            // Create VNet
            Console.WriteLine("--------Start create VNet--------");
            string    vnetName = vmName + "_vnet";
            AzureVnet vnet;

            if (!resourceGroup.VNets().TryGetValue(vnetName, out vnet))
            {
                vnet = resourceGroup.ConstructVnet("10.0.0.0/16");
                vnet = resourceGroup.VNets().CreateOrUpdateVNet(vnetName, vnet);
            }

            //create subnet
            Console.WriteLine("--------Start create Subnet--------");
            if (!vnet.Subnets.TryGetValue(subnetName, out subnet))
            {
                var nsg = resourceGroup.ConstructNsg(nsgName, 80);
                nsg    = resourceGroup.Nsgs().CreateOrUpdateNsgs(nsg);
                subnet = vnet.ConstructSubnet(subnetName, "10.0.0.0/24");
                subnet = vnet.Subnets.CreateOrUpdateSubnets(subnet);
            }
        }