public override void Execute()
        {
            var createMultipleVms = new CreateMultipleVms(Context);

            createMultipleVms.Execute();

            var sub = new AzureResourceManagerClient().GetSubscriptionOperations(Context.SubscriptionId);
            var rg  = sub.GetResourceGroupOperations(Context.RgName);
            var virtualMachineContainer = rg.GetVirtualMachineContainer();

            foreach (var response in virtualMachineContainer.List())
            {
                var virtualMachine = virtualMachineContainer.Get(response.Data.Id.Name);
                Debug.Assert(virtualMachine.Value.Data.Name.Equals(response.Data.Id.Name));
            }
            var virtualNetworkContainer = rg.GetVirtualNetworkContainer();

            foreach (var response in virtualNetworkContainer.List())
            {
                var virtualNetwork = virtualNetworkContainer.Get(response.Data.Id.Name);
                Debug.Assert(virtualNetwork.Value.Data.Name.Equals(response.Data.Id.Name));
                foreach (var subnetResponse in response.GetSubnetContainer().List())
                {
                    var actualSubnet = subnetResponse.Get();
                    var subnets      = response.GetSubnetContainer().Get(actualSubnet.Value.Data.Name);
                    Debug.Assert(subnets.Value.Data.Name.Equals(actualSubnet.Value.Data.Name));
                }
            }
            Console.WriteLine("\nDone all asserts passed ...");
        }
Beispiel #2
0
        public override void Execute()
        {
            var createVm = new CreateSingleVmExample(Context);

            createVm.Execute();
            var client = new AzureResourceManagerClient();

            //retrieve from lowest level, doesn't give ability to walk up and down the container structure
            var vmOp = client.GetResourceOperations <VirtualMachineOperations>(Context.SubscriptionId, Context.RgName, Context.VmName);
            var vm   = vmOp.Get().Value.Data;

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

            //retrieve from lowest level inside management package gives ability to walk up and down
            var rg  = client.GetResourceGroupOperations(Context.SubscriptionId, Context.RgName);
            var vm2 = rg.GetVirtualMachineOperations(Context.VmName).Get().Value.Data;

            Console.WriteLine($"Found VM {vm2.Id}");
        }