public VhdUploadContext AddAzureVhd(AddAzureVhdCmdletInfo cmdletInfo)
 {
     WindowsAzurePowershellCmdlet azurePowershellCmdlet = new WindowsAzurePowershellCmdlet(cmdletInfo);
     Collection<PSObject> result = azurePowershellCmdlet.Run();
     if (result.Count == 1)
     {
         return (VhdUploadContext)result[0].BaseObject;
     }
     return null;
 }
 public VhdUploadContext AddAzureVhd(FileInfo localFile, string destination, int numberOfUploaderThreads, bool overWrite)
 {
     var addAzureVhdCmdletInfo = new AddAzureVhdCmdletInfo(destination, localFile.FullName, numberOfUploaderThreads, overWrite);
     WindowsAzurePowershellCmdlet azurePowershellCmdlet = new WindowsAzurePowershellCmdlet(addAzureVhdCmdletInfo);
     Collection<PSObject> result = azurePowershellCmdlet.Run();
     if (result.Count == 1)
     {
         return (VhdUploadContext)result[0].BaseObject;
     }
     return null;
 }
        public Collection<DataVirtualHardDisk> GetAzureDataDisk(string vmName, string serviceName)
        {
            PersistentVMRoleContext vmRolectx = GetAzureVM(vmName, serviceName);

            GetAzureDataDiskCmdletInfo getAzureDataDiskCmdlet = new GetAzureDataDiskCmdletInfo(vmRolectx.VM);
            WindowsAzurePowershellCmdlet getAzureDataDisk = new WindowsAzurePowershellCmdlet(getAzureDataDiskCmdlet);

            Collection<DataVirtualHardDisk> hardDisks = new Collection<DataVirtualHardDisk>();
            foreach (PSObject disk in getAzureDataDisk.Run())
            {
                hardDisks.Add((DataVirtualHardDisk)disk.BaseObject);
            }
            return hardDisks;
        }
        public PersistentVMRoleContext ExportAzureVM(string vmName, string serviceName, string path)
        {
            //PersistentVMRoleContext result = new PersistentVMRoleContext
            ExportAzureVMCmdletInfo exportAzureVMCmdletInfo = new ExportAzureVMCmdletInfo(vmName, serviceName, path);
            WindowsAzurePowershellCmdlet exportAzureVMCmdlet = new WindowsAzurePowershellCmdlet(exportAzureVMCmdletInfo);

            Collection<PSObject> result = exportAzureVMCmdlet.Run();

            if (result.Count == 1)
            {
                return (PersistentVMRoleContext)result[0].BaseObject;
            }

            return null;
        }
        internal void ImportAzurePublishSettingsFile(string publishSettingsFile)
        {
            ImportAzurePublishSettingsFileCmdletInfo importAzurePublishSettingsFileCmdlet = new ImportAzurePublishSettingsFileCmdletInfo(publishSettingsFile);

            WindowsAzurePowershellCmdlet importAzurePublishSettingsFile = new WindowsAzurePowershellCmdlet(importAzurePublishSettingsFileCmdlet);
            importAzurePublishSettingsFile.Run();
        }
 public bool TestAzureServiceName(string serviceName)
 {
     TestAzureNameCmdletInfo testAzureNameCmdlet = new TestAzureNameCmdletInfo("Service", serviceName);
     WindowsAzurePowershellCmdlet testAzureName = new WindowsAzurePowershellCmdlet(testAzureNameCmdlet);
     Collection<bool> response = new Collection<bool>();
     foreach (PSObject result in testAzureName.Run())
     {
         response.Add((bool)result.BaseObject);
     }
     return response[0];
 }
 public Collection<StorageServicePropertiesOperationContext> GetAzureStorageAccount()
 {
     GetAzureStorageAccountCmdletInfo getAzureStorageAccountCmdlet = new GetAzureStorageAccountCmdletInfo();
     WindowsAzurePowershellCmdlet getAzureStorageAccount = new WindowsAzurePowershellCmdlet(getAzureStorageAccountCmdlet);
     Collection<StorageServicePropertiesOperationContext> storageAccounts = new Collection<StorageServicePropertiesOperationContext>();
     foreach (PSObject result in getAzureStorageAccount.Run())
     {
         storageAccounts.Add((StorageServicePropertiesOperationContext)result.BaseObject);
     }
     return storageAccounts;
 }
        public HostedServiceDetailedContext GetAzureService(string serviceName)
        {
            GetAzureServiceCmdletInfo getAzureServiceCmdletInfo = new GetAzureServiceCmdletInfo(serviceName);
            WindowsAzurePowershellCmdlet getAzureServiceCmdlet = new WindowsAzurePowershellCmdlet(getAzureServiceCmdletInfo);

            Collection<PSObject> result = getAzureServiceCmdlet.Run();
            if (result.Count == 1)
            {
                return (HostedServiceDetailedContext)result[0].BaseObject;
            }
            return null;
        }
 public void StopAzureVM(string vmName, string serviceName)
 {
     StopAzureVMCmdletInfo stopAzureVMCmdlet = new StopAzureVMCmdletInfo(vmName, serviceName);
     WindowsAzurePowershellCmdlet stopAzureVM = new WindowsAzurePowershellCmdlet(stopAzureVMCmdlet);
     stopAzureVM.Run();
 }
        private PersistentVM AddAzureDataDisk(AddAzureDataDiskConfig diskConfig)
        {
            AddAzureDataDiskCmdletInfo addAzureDataDiskCmdletInfo = new AddAzureDataDiskCmdletInfo(diskConfig);
            WindowsAzurePowershellCmdlet addAzureDataDiskCmdlet = new WindowsAzurePowershellCmdlet(addAzureDataDiskCmdletInfo);

            Collection<PSObject> result = addAzureDataDiskCmdlet.Run();
            if (result.Count == 1)
            {
                return (PersistentVM)result[0].BaseObject;
            }
            return null;
        }
        public PersistentVMRoleContext GetAzureVM(string vmName, string serviceName)
        {
            GetAzureVMCmdletInfo getAzureVMCmdletInfo = new GetAzureVMCmdletInfo(vmName, serviceName);
            WindowsAzurePowershellCmdlet getAzureVMCmdlet = new WindowsAzurePowershellCmdlet(getAzureVMCmdletInfo);

            Collection<PSObject> result = getAzureVMCmdlet.Run();
            if (result.Count == 1)
            {
                return (PersistentVMRoleContext)result[0].BaseObject;
            }
            return null;
        }
        public void RemoveAzureService(string serviceName)
        {
            RemoveAzureServiceCmdletInfo removeAzureServiceCmdletInfo = new RemoveAzureServiceCmdletInfo(serviceName);
            WindowsAzurePowershellCmdlet removeAzureServiceCmdlet = new WindowsAzurePowershellCmdlet(removeAzureServiceCmdletInfo);

            var result = removeAzureServiceCmdlet.Run();
        }
        private PersistentVM SetAzureEndPoint(AzureEndPointConfigInfo endPointConfig)
        {
            if (null != endPointConfig)
            {
                AddAzureEndpointCmdletInfo addAzureEndpointCmdletInfo = new AddAzureEndpointCmdletInfo(endPointConfig);
                WindowsAzurePowershellCmdlet addAzureEndpointCmdlet = new WindowsAzurePowershellCmdlet(addAzureEndpointCmdletInfo);

                Collection<PSObject> result = addAzureEndpointCmdlet.Run();
                if (result.Count == 1)
                {
                    return (PersistentVM)result[0].BaseObject;
                }
            }
            return null;
        }
 public StorageServicePropertiesOperationContext NewAzureStorageAccount(string storageName, string locationName)
 {
     NewAzureStorageAccountCmdletInfo newAzureStorageAccountCmdletInfo = new NewAzureStorageAccountCmdletInfo(storageName, locationName);
     WindowsAzurePowershellCmdlet newAzureStorageCmdlet = new WindowsAzurePowershellCmdlet(newAzureStorageAccountCmdletInfo);
     newAzureStorageCmdlet.Run();
     Collection<StorageServicePropertiesOperationContext> storageAccounts = GetAzureStorageAccount();
     foreach (StorageServicePropertiesOperationContext storageAccount in storageAccounts)
     {
         if (storageAccount.StorageAccountName == storageName)
             return storageAccount;
     }
     return null;
 }
        public void RemoveAzureDisk(string diskName, bool deleteVHD)
        {
            RemoveAzureDiskCmdletInfo removeAzureDiskCmdletInfo = new RemoveAzureDiskCmdletInfo(diskName, deleteVHD);
            WindowsAzurePowershellCmdlet removeAzureDiskCmdlet = new WindowsAzurePowershellCmdlet(removeAzureDiskCmdletInfo);

            Collection<PSObject> result = removeAzureDiskCmdlet.Run();
        }
        public ManagementOperationContext NewAzureService(string serviceName, string location)
        {
            var newAzureServiceCmdletInfo = new NewAzureServiceCmdletInfo(serviceName, location);
            var newAzureServiceCmdlet = new WindowsAzurePowershellCmdlet(newAzureServiceCmdletInfo);

            var result = newAzureServiceCmdlet.Run();

            if (result.Count == 1)
            {
                return (ManagementOperationContext)result[0].BaseObject;
            }
            return null;
        }
        public Collection<PersistentVM> ImportAzureVM(string path)
        {
            Collection<PersistentVM> result = new Collection<PersistentVM>();
            ImportAzureVMCmdletInfo importAzureVMCmdletInfo = new ImportAzureVMCmdletInfo(path);
            WindowsAzurePowershellCmdlet importAzureVMCmdlet = new WindowsAzurePowershellCmdlet(importAzureVMCmdletInfo);

            foreach (var vm in importAzureVMCmdlet.Run())
            {
                result.Add((PersistentVM)vm.BaseObject);
            }
            return result;
        }
 public StorageServiceKeyOperationContext GetAzureStorageAccountKey(string stroageAccountName)
 {
     var getAzureStorageKeyCmdletInfo = new GetAzureStorageKeyCmdletInfo(stroageAccountName);
     WindowsAzurePowershellCmdlet azurePowershellCmdlet = new WindowsAzurePowershellCmdlet(getAzureStorageKeyCmdletInfo);
     Collection<PSObject> result = azurePowershellCmdlet.Run();
     if (result.Count == 1)
     {
         return (StorageServiceKeyOperationContext)result[0].BaseObject;
     }
     return null;
 }
        internal void NewAzureService(string serviceName, string serviceLabel, string locationName)
        {
            NewAzureServiceCmdletInfo newAzureServiceCmdletInfo = new NewAzureServiceCmdletInfo(serviceName, serviceLabel, locationName);
            WindowsAzurePowershellCmdlet newAzureServiceCmdlet = new WindowsAzurePowershellCmdlet(newAzureServiceCmdletInfo);

            Collection<PSObject> result = newAzureServiceCmdlet.Run();
        }
        private PersistentVM SetNewAzureVMConfig(AzureVMConfigInfo vmConfig)
        {
            NewAzureVMConfigCmdletInfo newAzureVMConfigCmdletInfo = new NewAzureVMConfigCmdletInfo(vmConfig);
            WindowsAzurePowershellCmdlet newAzureServiceCmdlet = new WindowsAzurePowershellCmdlet(newAzureVMConfigCmdletInfo);

            Collection<PSObject> result = newAzureServiceCmdlet.Run();
            if (result.Count == 1)
            {
                return (PersistentVM)result[0].BaseObject;
            }
            return null;
        }
        internal Collection<ManagementOperationContext> NewAzureVM(string serviceName, PersistentVM[] VMs)
        {
            NewAzureVMCmdletInfo newAzureVMCmdletInfo = new NewAzureVMCmdletInfo(serviceName, VMs);
            WindowsAzurePowershellCmdlet newAzureVMCmdlet = new WindowsAzurePowershellCmdlet(newAzureVMCmdletInfo);

            Collection<ManagementOperationContext> newAzureVMs = new Collection<ManagementOperationContext>();
            foreach (PSObject result in newAzureVMCmdlet.Run())
            {
                newAzureVMs.Add((ManagementOperationContext)result.BaseObject);
            }
            return newAzureVMs;
        }
        private ManagementOperationContext UpdateAzureVM(string serviceName, string vmName, PersistentVM persistentVM)
        {
            UpdateAzureVMCmdletInfo updateAzureVMCmdletInfo = new UpdateAzureVMCmdletInfo(serviceName, vmName, persistentVM);
            WindowsAzurePowershellCmdlet updateAzureVMCmdlet = new WindowsAzurePowershellCmdlet(updateAzureVMCmdletInfo);

            Collection<PSObject> result = updateAzureVMCmdlet.Run();
            if (result.Count == 1)
            {
                return (ManagementOperationContext)result[0].BaseObject;
            }
            return null;
        }
 public void RemoveAzureStorageAccount(string storageAccountName)
 {
     var removeAzureStorageAccountCmdletInfo = new RemoveAzureStorageAccountCmdletInfo(storageAccountName);
     var azurePowershellCmdlet = new WindowsAzurePowershellCmdlet(removeAzureStorageAccountCmdletInfo);
     Collection<PSObject> result = azurePowershellCmdlet.Run();
 }
        public Collection<SubscriptionData> GetAzureSubscription()
        {
            GetAzureSubscriptionCmdletInfo getAzureSubscriptionCmdlet = new GetAzureSubscriptionCmdletInfo();
            WindowsAzurePowershellCmdlet getAzureSubscription = new WindowsAzurePowershellCmdlet(getAzureSubscriptionCmdlet);
            Collection<SubscriptionData> subscriptions = new Collection<SubscriptionData>();
            foreach (PSObject result in getAzureSubscription.Run())
            {
                subscriptions.Add((SubscriptionData)result.BaseObject);
            }

            return subscriptions;
        }
        private PersistentVM SetAzureVMSize(SetAzureVMSizeConfig sizeCfg)
        {
            SetAzureVMSizeCmdletInfo setAzureVMSizeCmdletInfo = new SetAzureVMSizeCmdletInfo(sizeCfg);
            WindowsAzurePowershellCmdlet setAzureDataDiskCmdlet = new WindowsAzurePowershellCmdlet(setAzureVMSizeCmdletInfo);

            Collection<PSObject> result = setAzureDataDiskCmdlet.Run();
            if (result.Count == 1)
            {
                return (PersistentVM)result[0].BaseObject;
            }
            return null;
        }
        public void RemoveAzureVM(string vmName, string serviceName)
        {
            RemoveAzureVMCmdletInfo removeAzureVMCmdletInfo = new RemoveAzureVMCmdletInfo(vmName, serviceName);
            WindowsAzurePowershellCmdlet removeAzureVMCmdlet = new WindowsAzurePowershellCmdlet(removeAzureVMCmdletInfo);

            Collection<PSObject> result = removeAzureVMCmdlet.Run();
        }
        private PersistentVM SetProvisioningConfig(AzureProvisioningConfigInfo provConfig)
        {
            AddAzureProvisioningConfigCmdletInfo addAzureProvisioningConfigCmdletInfog = new AddAzureProvisioningConfigCmdletInfo(provConfig);
            WindowsAzurePowershellCmdlet addAzureProvisioningConfigCmdlet = new WindowsAzurePowershellCmdlet(addAzureProvisioningConfigCmdletInfog);

            Collection<PSObject> result = addAzureProvisioningConfigCmdlet.Run();
            if (result.Count == 1)
            {
                return (PersistentVM)result[0].BaseObject;
            }
            return null;
        }
 public void RestartAzureVM(string vmName, string serviceName)
 {
     RestartAzureVMCmdletInfo restartAzureVMCmdlet = new RestartAzureVMCmdletInfo(vmName, serviceName);
     WindowsAzurePowershellCmdlet restartAzureVM = new WindowsAzurePowershellCmdlet(restartAzureVMCmdlet);
     restartAzureVM.Run();
 }
        public SubscriptionData SetDefaultAzureSubscription(string subscriptionName)
        {
            SetAzureSubscriptionCmdletInfo setAzureSubscriptionCmdlet = new SetAzureSubscriptionCmdletInfo(subscriptionName);
            WindowsAzurePowershellCmdlet setAzureSubscription = new WindowsAzurePowershellCmdlet(setAzureSubscriptionCmdlet);
            setAzureSubscription.Run();

            Collection<SubscriptionData> subscriptions = GetAzureSubscription();
            foreach (SubscriptionData subscription in subscriptions)
            {
                if (subscription.SubscriptionName == subscriptionName)
                {
                    return subscription;
                }
            }
            return null;
        }
        public void GetAzureRemoteDesktopFile(string vmName, string serviceName, string localPath, bool launch)
        {
            GetAzureRemoteDesktopFileCmdletInfo getAzureRemoteDesktopFileCmdletInfo = new GetAzureRemoteDesktopFileCmdletInfo(vmName, serviceName, localPath, launch);
            WindowsAzurePowershellCmdlet getAzureRemoteDesktopFileCmdlet = new WindowsAzurePowershellCmdlet(getAzureRemoteDesktopFileCmdletInfo);

            Collection<PSObject> result = getAzureRemoteDesktopFileCmdlet.Run();
        }