Exemple #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);
                }
            });
        }
        // 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)));
            });
        }