예제 #1
0
        public override void ExecuteCmdlet()
        {
            ExecutionBlock(() =>
            {
                base.ExecuteCmdlet();
                InitializeAzureBackupCmdlet(String.Empty, String.Empty);

                if (ResourceGroupName != null && Name != null)
                {
                    var backupVault = AzureBackupClient.GetVault(ResourceGroupName, Name);
                    WriteObject(VaultHelpers.GetCmdletVault(backupVault, AzureBackupClient.GetStorageTypeDetails(VaultHelpers.GetResourceGroup(backupVault.Id), backupVault.Name)));
                }
                else if (ResourceGroupName != null)
                {
                    var backupVaults = AzureBackupClient.GetVaultsInResourceGroup(ResourceGroupName);
                    WriteObject(GetCmdletVaults(backupVaults), true);
                }
                else
                {
                    var backupVaults = AzureBackupClient.GetVaults();

                    if (Name != null)
                    {
                        backupVaults = backupVaults.Where(x => x.Name.Equals(Name, StringComparison.InvariantCultureIgnoreCase));
                    }
                    WriteObject(GetCmdletVaults(backupVaults), true);
                }
            });
        }
예제 #2
0
        private IEnumerable <AzureRMBackupVault> GetCmdletVaults(IEnumerable <AzureBackupVault> backupVaults)
        {
            List <AzureRMBackupVault> resultList = new List <AzureRMBackupVault>();

            if (backupVaults != null)
            {
                foreach (var backupVault in backupVaults)
                {
                    resultList.Add(VaultHelpers.GetCmdletVault(backupVault, AzureBackupClient.GetStorageTypeDetails(VaultHelpers.GetResourceGroup(backupVault.Id), backupVault.Name)));
                }
            }

            return(resultList);
        }
        // TODO: Add support for tags
        //[Alias("Tags")]
        //[Parameter(Mandatory = false, HelpMessage = AzureBackupCmdletHelpMessage.ResourceTags)]
        //public Hashtable[] Tag { get; set; }

        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            ExecutionBlock(() =>
            {
                if (Storage != 0)
                {
                    WriteDebug(String.Format(Resources.SettingStorageType, Storage));

                    AzureBackupClient.UpdateStorageType(Vault.ResourceGroupName, Vault.Name, Storage.ToString());
                }

                var backupVault = AzureBackupClient.GetVault(Vault.ResourceGroupName, Vault.Name);
                WriteObject(VaultHelpers.GetCmdletVault(backupVault, AzureBackupClient.GetStorageTypeDetails(Vault.ResourceGroupName, Vault.Name)));
            });
        }
예제 #4
0
        // TODO: Add support for tags
        //[Alias("Tags")]
        //[Parameter(Mandatory = false, HelpMessage = AzureBackupCmdletHelpMessage.ResourceTags)]
        //public Hashtable[] Tag { get; set; }

        public override void ExecuteCmdlet()
        {
            ExecutionBlock(() =>
            {
                base.ExecuteCmdlet();
                InitializeAzureBackupCmdlet(ResourceGroupName, Name);

                WriteDebug(String.Format(Resources.CreatingBackupVault, ResourceGroupName, Name));

                var createdVault = AzureBackupClient.CreateOrUpdateAzureBackupVault(ResourceGroupName, Name, Region);

                if (Storage != 0)
                {
                    WriteDebug(String.Format(Resources.SettingStorageType, Storage));

                    AzureBackupClient.UpdateStorageType(ResourceGroupName, Name, Storage.ToString());
                }

                WriteObject(VaultHelpers.GetCmdletVault(createdVault, AzureBackupClient.GetStorageTypeDetails(VaultHelpers.GetResourceGroup(createdVault.Id), createdVault.Name)));
            });
        }