public ManagementController(ManagementControllerParameters parameters)
        {
            _parameters = parameters;

            // To authenticate against the Microsoft Azure service management API we require management certificate
            // load this from a publish settings file and later use it with the Service Management Libraries
            var credentials = GetSubscriptionCloudCredentials(parameters.PublishSettingsFilePath);

            // Create a management client and a virtual network management client
            _managementClient = CloudContext.Clients.CreateManagementClient(credentials);
            _virtualNetworkManagementClient = CloudContext.Clients.CreateVirtualNetworkManagementClient(credentials);
        }
        public ManagementController(ManagementControllerParameters parameters)
        {
            _parameters = parameters;

            // To authenticate against the Microsoft Azure service management API we require management certificate
            // load this from a publish settings file and later use it with the Service Management Libraries
            var credentials = GetSubscriptionCloudCredentials(parameters.PublishSettingsFilePath);

            // Create a management client and a virtual network management client
            _managementClient = CloudContext.Clients.CreateManagementClient(credentials);
            _virtualNetworkManagementClient = CloudContext.Clients.CreateVirtualNetworkManagementClient(credentials);
        }
예제 #3
0
        private static async Task DemoVirtualNetworkOperations(ManagementControllerParameters managementControllerParameters)
        {
            using (var controller = new ManagementController(managementControllerParameters))
            {
                Console.WriteLine("1. List virtual networks");
                ConsoleContinuePrompt("list");
                controller.ListVirtualNetworks();
                Console.WriteLine("\n...Complete\n");

                Console.WriteLine("2. Get virtual network configuration");
                ConsoleContinuePrompt("get configuration");
                await controller.GetVirtualNetworkConfigurationAsync();

                Console.WriteLine("\n...Complete\n");

                Console.WriteLine("3. Add virtual network");
                ConsoleContinuePrompt("add");
                await controller.AddVirtualNetworkSiteAsync();

                Console.WriteLine("\n...Complete\n");

                Console.WriteLine("4. Set new virtual network configuration");
                Console.WriteLine("********************************************************************************");
                Console.WriteLine("         Your existing virtual network configuration will be replaced.");
                Console.WriteLine("         This operation will fail if you have virtual networks in use ");
                Console.WriteLine("         that cannot be deleted.");
                Console.WriteLine("********************************************************************************");
                ConsoleContinuePrompt("set");
                await controller.SetVirtualNetworkConfigurationAsync();

                Console.WriteLine("\n...Complete\n");

                Console.WriteLine("5. Restore original configuraiton");
                ConsoleContinuePrompt("restore");
                await controller.CleanUpAsync();

                Console.WriteLine("\n...Complete\n");

                Console.WriteLine("Done. Press a key to exit");
                Console.ReadKey();
            }
        }
예제 #4
0
        static void Main(string[] args)
        {
            //********************************************************************************************************
            // The Microsoft Azure Management Libraries are inteded for developers who want to automate
            // the management, provisioning, deprovisioning and test of cloud infrastructure with ease.
            // These services support Microsoft Azure Virtual Machines, Hosted Services, Storage, Virtual Networks,
            // Web Sites and core data center infrastructure management. If you dont have a Microsoft Azure
            // subscription you can get a FREE trial account here:
            // http://go.microsoft.com/fwlink/?LinkId=330212
            //
            // TODO: Perform the following steps before running the sample
            //  1. Download your *.publishsettings file from the Microsoft Azure management portal and save to
            //      to your local dive http://go.microsoft.com/fwlink/?LinkID=276844
            //  2. Set the PublishSettingsFilePath property below. Do not enable Remote Desktop, as this
            //      process won't upload your certificate.
            //  3. Review the properties AffinityGroupName, VirtualNetworkSite and VirtualNetworkConfig below
            //      VirtualNetworkSite will be used to add a new virtual network to your existing configuraiton.
            //      VirtualNetworkConfig contains a sample network configuration that will replace your
            //      existing network configuration.
            //  4. Run
            //********************************************************************************************************

            var serviceParameters = new ManagementControllerParameters
            {
                PublishSettingsFilePath = @"C:\Your.publishsettings",
                AffinityGroupName       = @"TestAffinityGroup",
                VirtualNetworkSite      =
                    @"<VirtualNetworkSite name=""test"" AffinityGroup=""{0}""
                          xmlns=""http://schemas.microsoft.com/ServiceHosting/2011/07/NetworkConfiguration"">
                        <AddressSpace>
                          <AddressPrefix>10.0.0.0/8</AddressPrefix>
                        </AddressSpace>
                        <Subnets>
                          <Subnet name=""subnet1"">
                            <AddressPrefix>10.10.1.0/24</AddressPrefix>
                          </Subnet>
                          <Subnet name=""subnet2"">
                            <AddressPrefix>10.10.2.0/24</AddressPrefix>
                          </Subnet>
                        </Subnets>
                      </VirtualNetworkSite>",
                VirtualNetworkConfig =
                    @"<?xml version=""1.0"" encoding=""utf-8""?>
                    <NetworkConfiguration xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" 
                        xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" 
                        xmlns=""http://schemas.microsoft.com/ServiceHosting/2011/07/NetworkConfiguration"">
                      <VirtualNetworkConfiguration>
                        <Dns>
                          <DnsServers>
                            <DnsServer name=""DNS"" IPAddress=""10.1.0.4"" />
                          </DnsServers>
                        </Dns>
                        <LocalNetworkSites>
                          <LocalNetworkSite name=""MyLocalNetwork1"">
                            <AddressSpace>
                              <AddressPrefix>192.168.0.0/24</AddressPrefix>
                            </AddressSpace>
                            <VPNGatewayAddress>1.1.1.1</VPNGatewayAddress>
                          </LocalNetworkSite>
                        </LocalNetworkSites>
                        <VirtualNetworkSites>
	                       <VirtualNetworkSite name=""test1"" AffinityGroup=""{0}"">
                            <AddressSpace>
                              <AddressPrefix>10.0.0.0/8</AddressPrefix>
                            </AddressSpace>
                            <Subnets>
                              <Subnet name=""subnet1"">
                                <AddressPrefix>10.10.1.0/24</AddressPrefix>
                              </Subnet>
                              <Subnet name=""subnet2"">
                                <AddressPrefix>10.10.2.0/24</AddressPrefix>
                              </Subnet>
                            </Subnets>
		                    <DnsServersRef>
                              <DnsServerRef name=""DNS"" />
                            </DnsServersRef>
                          </VirtualNetworkSite>
	                       <VirtualNetworkSite name=""test2"" AffinityGroup=""{0}"">
                            <AddressSpace>
                              <AddressPrefix>10.0.0.0/8</AddressPrefix>
                            </AddressSpace>
                            <Subnets>
                                <Subnet name=""Subnet-1"">
                                  <AddressPrefix>10.1.0.0/16</AddressPrefix>
                                </Subnet>
                                <Subnet name=""Subnet-2"">
                                  <AddressPrefix>10.2.0.0/16</AddressPrefix>
                                </Subnet>
                                <Subnet name=""Subnet-3"">
                                  <AddressPrefix>10.3.0.0/16</AddressPrefix>
                                </Subnet>
                            </Subnets>
                            <DnsServersRef>
                              <DnsServerRef name=""DNS"" />
                            </DnsServersRef>
                          </VirtualNetworkSite>
                        </VirtualNetworkSites>
                      </VirtualNetworkConfiguration>
                    </NetworkConfiguration>"
            };

            Task.WaitAll(DemoVirtualNetworkOperations(serviceParameters));
        }
예제 #5
0
        static void Main(string[] args)
        {
            //********************************************************************************************************
            // The Microsoft Azure Management Libraries are inteded for developers who want to automate 
            // the management, provisioning, deprovisioning and test of cloud infrastructure with ease.            
            // These services support Microsoft Azure Virtual Machines, Hosted Services, Storage, Virtual Networks, 
            // Web Sites and core data center infrastructure management. If you dont have a Microsoft Azure 
            // subscription you can get a FREE trial account here:
            // http://go.microsoft.com/fwlink/?LinkId=330212
            //
            // TODO: Perform the following steps before running the sample 
            //  1. Download your *.publishsettings file from the Microsoft Azure management portal and save to
            //      to your local dive http://go.microsoft.com/fwlink/?LinkID=276844
            //  2. Set the PublishSettingsFilePath property below. Do not enable Remote Desktop, as this 
            //      process won't upload your certificate. 
            //  3. Review the properties AffinityGroupName, VirtualNetworkSite and VirtualNetworkConfig below
            //      VirtualNetworkSite will be used to add a new virtual network to your existing configuraiton.
            //      VirtualNetworkConfig contains a sample network configuration that will replace your 
            //      existing network configuration.
            //  4. Run
            //********************************************************************************************************

            var serviceParameters = new ManagementControllerParameters
            {
                PublishSettingsFilePath = @"C:\Your.publishsettings",
                AffinityGroupName = @"TestAffinityGroup",
                VirtualNetworkSite =
                      @"<VirtualNetworkSite name=""test"" AffinityGroup=""{0}""
                          xmlns=""http://schemas.microsoft.com/ServiceHosting/2011/07/NetworkConfiguration"">
                        <AddressSpace>
                          <AddressPrefix>10.0.0.0/8</AddressPrefix>
                        </AddressSpace>
                        <Subnets>
                          <Subnet name=""subnet1"">
                            <AddressPrefix>10.10.1.0/24</AddressPrefix>
                          </Subnet>
                          <Subnet name=""subnet2"">
                            <AddressPrefix>10.10.2.0/24</AddressPrefix>
                          </Subnet>
                        </Subnets>
                      </VirtualNetworkSite>",
                VirtualNetworkConfig =
                    @"<?xml version=""1.0"" encoding=""utf-8""?>
                    <NetworkConfiguration xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" 
                        xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" 
                        xmlns=""http://schemas.microsoft.com/ServiceHosting/2011/07/NetworkConfiguration"">
                      <VirtualNetworkConfiguration>
                        <Dns>
                          <DnsServers>
                            <DnsServer name=""DNS"" IPAddress=""10.1.0.4"" />
                          </DnsServers>
                        </Dns>
                        <LocalNetworkSites>
                          <LocalNetworkSite name=""MyLocalNetwork1"">
                            <AddressSpace>
                              <AddressPrefix>192.168.0.0/24</AddressPrefix>
                            </AddressSpace>
                            <VPNGatewayAddress>1.1.1.1</VPNGatewayAddress>
                          </LocalNetworkSite>
                        </LocalNetworkSites>
                        <VirtualNetworkSites>
	                       <VirtualNetworkSite name=""test1"" AffinityGroup=""{0}"">
                            <AddressSpace>
                              <AddressPrefix>10.0.0.0/8</AddressPrefix>
                            </AddressSpace>
                            <Subnets>
                              <Subnet name=""subnet1"">
                                <AddressPrefix>10.10.1.0/24</AddressPrefix>
                              </Subnet>
                              <Subnet name=""subnet2"">
                                <AddressPrefix>10.10.2.0/24</AddressPrefix>
                              </Subnet>
                            </Subnets>
		                    <DnsServersRef>
                              <DnsServerRef name=""DNS"" />
                            </DnsServersRef>
                          </VirtualNetworkSite>
	                       <VirtualNetworkSite name=""test2"" AffinityGroup=""{0}"">
                            <AddressSpace>
                              <AddressPrefix>10.0.0.0/8</AddressPrefix>
                            </AddressSpace>
                            <Subnets>
                                <Subnet name=""Subnet-1"">
                                  <AddressPrefix>10.1.0.0/16</AddressPrefix>
                                </Subnet>
                                <Subnet name=""Subnet-2"">
                                  <AddressPrefix>10.2.0.0/16</AddressPrefix>
                                </Subnet>
                                <Subnet name=""Subnet-3"">
                                  <AddressPrefix>10.3.0.0/16</AddressPrefix>
                                </Subnet>
                            </Subnets>
                            <DnsServersRef>
                              <DnsServerRef name=""DNS"" />
                            </DnsServersRef>
                          </VirtualNetworkSite>
                        </VirtualNetworkSites>
                      </VirtualNetworkConfiguration>
                    </NetworkConfiguration>"
            };

            Task.WaitAll(DemoVirtualNetworkOperations(serviceParameters));
        }
예제 #6
0
        private static async Task DemoVirtualNetworkOperations(ManagementControllerParameters managementControllerParameters)
        {
            using (var controller = new ManagementController(managementControllerParameters))
            {
                Console.WriteLine("1. List virtual networks");
                ConsoleContinuePrompt("list");
                controller.ListVirtualNetworks();
                Console.WriteLine("\n...Complete\n");
                
                Console.WriteLine("2. Get virtual network configuration");
                ConsoleContinuePrompt("get configuration");
                await controller.GetVirtualNetworkConfigurationAsync();
                Console.WriteLine("\n...Complete\n");
                
                Console.WriteLine("3. Add virtual network");
                ConsoleContinuePrompt("add");
                await controller.AddVirtualNetworkSiteAsync();
                Console.WriteLine("\n...Complete\n");
                
                Console.WriteLine("4. Set new virtual network configuration");
                Console.WriteLine("********************************************************************************");
                Console.WriteLine("         Your existing virtual network configuration will be replaced.");
                Console.WriteLine("         This operation will fail if you have virtual networks in use ");
                Console.WriteLine("         that cannot be deleted.");
                Console.WriteLine("********************************************************************************");
                ConsoleContinuePrompt("set");
                await controller.SetVirtualNetworkConfigurationAsync();
                Console.WriteLine("\n...Complete\n");
                
                Console.WriteLine("5. Restore original configuraiton");
                ConsoleContinuePrompt("restore");
                await controller.CleanUpAsync();
                Console.WriteLine("\n...Complete\n");

                Console.WriteLine("Done. Press a key to exit"); 
                Console.ReadKey();
            }
        }