Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ public static List<ProtectableItemBase> GetProtectableItemModelList(IEnumerable<
List<ProtectableItemBase> itemModels = new List<ProtectableItemBase>();

foreach (var protectableItem in protectableItems)
{
{
itemModels.Add(GetProtectableItemModel(protectableItem));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="4.1.9-preview" />
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="4.2.0-preview" />
<PackageReference Include="TimeZoneConverter" Version="3.0.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public class AzureVmWorkloadContainer : AzureContainer
/// </summary>
public string HealthStatus { get; set; }

/// <summary>
/// Gets or sets host server name of the container.
/// </summary>
public string ServerName { get; set; }

/// <summary>
/// Gets or sets additional details of a workload container.
/// </summary>
Expand All @@ -56,6 +61,12 @@ public AzureVmWorkloadContainer(ProtectionContainerResource protectionContainerR
Id = protectionContainerResource.Id;
SourceResourceId = protectionContainer.SourceResourceId;
HealthStatus = protectionContainer.HealthStatus;

if(protectionContainer.ExtendedInfo != null)
{
ServerName = protectionContainer.ExtendedInfo.HostServerName;
}

ExtendedInfo = new List<AzureVmWorkloadContainerExtendedInfo>();
WorkloadsPresent = "";
foreach (var inquiryDetail in protectionContainer.ExtendedInfo.InquiryInfo.InquiryDetails)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Management.RecoveryServices.Backup.Models;
using System.Collections.Generic;
using CmdletModel = Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models;

namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
Expand Down Expand Up @@ -63,6 +64,11 @@ public class AzureWorkloadProtectableItem : ProtectableItemBase
/// </summary>
public bool? IsAutoProtected { get; set; }

/// <summary>
/// Auto protection policy for protectable item
/// </summary>
public string AutoProtectionPolicy { get; set; }

/// <summary>
/// for instance or AG, indicates number of DB's present
/// </summary>
Expand All @@ -78,6 +84,11 @@ public class AzureWorkloadProtectableItem : ProtectableItemBase
/// </summary>
public PreBackupValidation Prebackupvalidation { get; set; }

/// <summary>
/// NodesList for SQLAG protectable objects
/// </summary>
public IList<DistributedNodesInfo> NodesList { get; set; }

/// <summary>
/// Constructor. Takes the service client object representing the protected item
/// and converts it in to the PS protected item model
Expand All @@ -100,7 +111,8 @@ public AzureWorkloadProtectableItem(WorkloadProtectableItemResource workloadProt
Subinquireditemcount = protectedItem.Subinquireditemcount;
Subprotectableitemcount = protectedItem.Subprotectableitemcount;
Prebackupvalidation = protectedItem.Prebackupvalidation;
ProtectableItemType = workloadProtectableItemResource.Properties.GetType().ToString();
ProtectableItemType = workloadProtectableItemResource.Properties.GetType().ToString();

if (workloadProtectableItemResource.Properties.GetType() == typeof(AzureVmWorkloadSQLAvailabilityGroupProtectableItem))
{
ProtectableItemType = CmdletModel.ProtectableItemType.SQLAvailabilityGroup.ToString();
Expand All @@ -112,7 +124,7 @@ public AzureWorkloadProtectableItem(WorkloadProtectableItemResource workloadProt
else if (workloadProtectableItemResource.Properties.GetType() == typeof(AzureVmWorkloadSQLDatabaseProtectableItem))
{
ProtectableItemType = CmdletModel.ProtectableItemType.SQLDataBase.ToString();
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public enum BackupManagementType
MAB,

/// <summary>
/// represents that the BackupManagementType is Not Applicable.
/// Represents that the BackupManagementType is Not Applicable.
/// </summary>
NA
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="4.1.9-preview" />
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="4.2.0-preview" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -620,19 +620,32 @@ public void TriggerInquiry(string vaultName, string vaultResourceGroupName,
}
}

public List<ItemBase> GetMABProtectedItems(string vaultName, string resourceGroupName)
public List<ItemBase> GetMABProtectedItems(string vaultName, string resourceGroupName, ContainerBase container = null)
{
ODataQuery<ProtectedItemQueryObject> queryParams =
new ODataQuery<ProtectedItemQueryObject>(
q => q.BackupManagementType == ServiceClientModel.BackupManagementType.MAB);

q => q.BackupManagementType == ServiceClientModel.BackupManagementType.MAB);

List<ProtectedItemResource> protectedItems = ServiceClientAdapter.ListProtectedItem(
queryParams,
null,
vaultName: vaultName,
resourceGroupName: resourceGroupName);

// filter by Container Name if given
if (container != null)
{
protectedItems = protectedItems.Where(protectedItem =>
{
Dictionary<CmdletModel.UriEnums, string> dictionary = HelperUtils.ParseUri(protectedItem.Id);
string containerUri = HelperUtils.GetContainerUri(dictionary, protectedItem.Id);

var delimIndex = containerUri.IndexOf(';');
string containerName = containerUri.Substring(delimIndex + 1);
return containerName.ToLower().Equals(container.Name.ToLower());
}).ToList();
}

return ConversionHelpers.GetItemModelList(protectedItems);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public IPsBackupProvider GetProviderInstance
}
break;
case ContainerType.Windows:
if (backupManagementType == BackupManagementType.MARS)
if (backupManagementType == BackupManagementType.MARS || backupManagementType == BackupManagementType.MAB)
{
providerType = PsBackupProviderTypes.Mab;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="4.1.9-preview" />
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="4.2.0-preview" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,28 @@ public IEnumerable<ProtectionContainerResource> ListContainers(
return HelperUtils.GetPagedList(listAsync, listNextAsync);
}

/// <summary>
/// Fetches a particular protection container in the vault
/// </summary>
/// <param name="vaultName"></param>
/// <param name="resourceGroupName"></param>
/// <param name="containerName"></param>
/// <returns></returns>
public ProtectionContainerResource GetContainer(
string vaultName = null,
string resourceGroupName = null,
string containerName = null)
{
ProtectionContainerResource container = BmsAdapter.Client.ProtectionContainers.GetWithHttpMessagesAsync(
vaultName ?? BmsAdapter.GetResourceName(),
resourceGroupName ?? BmsAdapter.GetResourceGroupName(),
AzureFabricName,
containerName,
cancellationToken: BmsAdapter.CmdletCancellationToken).Result.Body;

return container;
}

/// <summary>
/// Fetches backup engines in the vault according to the query params
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,15 @@ public RestAzureNS.AzureOperationResponse DeleteProtectionIntent(
protectedItemName,
cancellationToken: BmsAdapter.CmdletCancellationToken).Result;
}

/// <summary>
/// List protection intents
/// </summary>
/// <param name="protectedItemName">Name of the item</param>
/// <param name="request">Protected item create or update request</param>
/// <returns>Job created in the service for this operation</returns>
/// <param name="queryFilter"></param>
/// <param name="skipToken"></param>
/// <param name="vaultName"></param>
/// <param name="resourceGroupName"></param>
/// <returns>List of protection intents resource</returns>
public List<ProtectionIntentResource> ListProtectionIntent(
ODataQuery<ProtectionIntentQueryObject> queryFilter,
string skipToken = default(string),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public BackupResourceVaultConfigResource GetVaultProperty(string vaultName, stri
/// <returns>Azure Resource Storage response object.</returns>
public BackupResourceConfigResource GetVaultStorageType(string resouceGroupName, string vaultName)
{
return BmsAdapter.Client.BackupResourceStorageConfigs.GetWithHttpMessagesAsync(
return BmsAdapter.Client.BackupResourceStorageConfigsNonCRR.GetWithHttpMessagesAsync(
vaultName, resouceGroupName).Result.Body;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices" Version="4.3.2-preview" />
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="4.1.9-preview" />
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="4.2.0-preview" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.4.1" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="49.1.0" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.6.0" />
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices" Version="4.3.2-preview" />
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="4.1.9-preview" />
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="4.2.0-preview" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,29 @@ function Get-AzureVmWorkloadContainer
{
$resourceGroupName = "pstestwlRG1bca8"
$vaultName = "pstestwlRSV1bca8"
$containerName = "PSTestVM235870"
$resourceId = "/subscriptions/38304e13-357e-405e-9e9a-220351dcce8c/resourceGroups/PSTestRG235879ba/providers/Microsoft.Compute/virtualMachines/PSTestVM235870"
$containerName = "pstestvm8895"
# $containerName = "PSTestVM235870"
# $resourceId = "/subscriptions/38304e13-357e-405e-9e9a-220351dcce8c/resourceGroups/PSTestRG235879ba/providers/Microsoft.Compute/virtualMachines/PSTestVM235870"

try
{
$vault = Get-AzRecoveryServicesVault -ResourceGroupName $resourceGroupName -Name $vaultName

#Register container
$container = Register-AzRecoveryServicesBackupContainer `
<# $container = Register-AzRecoveryServicesBackupContainer `
-ResourceId $resourceId `
-BackupManagementType AzureWorkload `
-WorkloadType MSSQL `
-VaultId $vault.ID `
-Force
Assert-AreEqual $container.Status "Registered"
Assert-AreEqual $container.Status "Registered" #>

# VARIATION-1: Get All Containers with only mandatory parameters
$containers = Get-AzRecoveryServicesBackupContainer `
-VaultId $vault.ID `
-ContainerType AzureVMAppContainer `
-Status Registered;
Assert-True { $containers.FriendlyName -contains $containerName }
Assert-True { $containers[0].FriendlyName -contains $containerName }

# VARIATION-2: Get Containers with friendly name filter
$containers = Get-AzRecoveryServicesBackupContainer `
Expand All @@ -58,7 +59,7 @@ function Get-AzureVmWorkloadContainer
-ContainerType AzureVMAppContainer `
-Status Registered `
-ResourceGroupName $resourceGroupName;
Assert-True { $containers.FriendlyName -contains $containerName }
Assert-True { $containers[0].FriendlyName -contains $containerName }

# VARIATION-4: Get Containers with friendly name and resource group filters
$containers = Get-AzRecoveryServicesBackupContainer `
Expand All @@ -72,9 +73,9 @@ function Get-AzureVmWorkloadContainer
finally
{
#Unregister container
Unregister-AzRecoveryServicesBackupContainer `
<# Unregister-AzRecoveryServicesBackupContainer `
-VaultId $vault.ID `
-Container $containers
-Container $containers #>
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function Create-VM(

$UserName='demouser'
$PasswordString = $(Get-RandomSuffix 12)
$Password=$PasswordString| ConvertTo-SecureString -Force -AsPlainText
$Password=$PasswordString + "Aa." | ConvertTo-SecureString -Force -AsPlainText
$Credential=New-Object PSCredential($UserName,$Password)

$tags = @{"MabUsed"="Yes"}
Expand Down
Loading