コード例 #1
0
        private static void SetTagsOnVm()
        {
            //make sure vm exists
            CreateSingleVmExample();

            AzureResourceGroup rg = AzureClient.GetResourceGroup(subscriptionId, rgName);
            AzureVm            vm = rg.Vms()[vmName];

            vm.AddTag("tagkey", "tagvalue");
        }
コード例 #2
0
        private static void StartFromVm()
        {
            // TODO: Look at VM nic/nsg operations on VM
            //make sure vm exists
            CreateSingleVmExample();

            //retrieve from lowest level, doesn't give ability to walk up and down the container structure
            AzureVm vm = VmCollection.GetVm(subscriptionId, rgName, vmName);

            Console.WriteLine("Found VM {0}", vm.Id);


            //retrieve from lowest level inside management package gives ability to walk up and down
            AzureResourceGroup rg  = AzureClient.GetResourceGroup(subscriptionId, rgName);
            AzureVm            vm2 = rg.Vms()[vmName];

            Console.WriteLine("Found VM {0}", vm2.Id);
        }
コード例 #3
0
        private static void CreateMultipleVmShutdownSome()
        {
            AzureResourceGroup resourceGroup = CreateMultipleVms();

            resourceGroup.Vms().Select(vm =>
            {
                var parts = vm.Name.Split('-');
                var n     = Convert.ToInt32(parts[parts.Length - 2]);
                return(vm, n);
            })
            .Where(tuple => tuple.n % 2 == 0)
            .ToList()
            .ForEach(tuple =>
            {
                Console.WriteLine("Stopping {0}", tuple.vm.Name);
                tuple.vm.Stop();
                Console.WriteLine("Starting {0}", tuple.vm.Name);
                tuple.vm.Start();
            });
        }