diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/Commands.AzureBackup.Test.csproj b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/Commands.AzureBackup.Test.csproj
index 5e28bc7689e5..f0fdd55696d6 100644
--- a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/Commands.AzureBackup.Test.csproj
+++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/Commands.AzureBackup.Test.csproj
@@ -40,8 +40,7 @@
..\..\..\packages\Microsoft.Azure.Common.Authentication.1.1.3-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll
- False
- ..\Commands.AzureBackup\Resources\Microsoft.Azure.Management.BackupServicesManagement.dll
+ ..\..\..\packages\Microsoft.Azure.Management.BackupServices.1.0.4-preview\lib\net40\Microsoft.Azure.Management.BackupServicesManagement.dll
False
diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/packages.config b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/packages.config
index 347d88dceca1..f3c649040ddb 100644
--- a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/packages.config
+++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/packages.config
@@ -4,7 +4,7 @@
-
+
diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Commands.AzureBackup.csproj b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Commands.AzureBackup.csproj
index 8edddbb401fe..aede1c1e2b9f 100644
--- a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Commands.AzureBackup.csproj
+++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Commands.AzureBackup.csproj
@@ -57,8 +57,7 @@
..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll
- False
- Resources\Microsoft.Azure.Management.BackupServicesManagement.dll
+ ..\..\..\packages\Microsoft.Azure.Management.BackupServices.1.0.4-preview\lib\net40\Microsoft.Azure.Management.BackupServicesManagement.dll
False
diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Helpers/VaultHelpers.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Helpers/VaultHelpers.cs
index 2bb8d3805a01..818c318ef558 100644
--- a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Helpers/VaultHelpers.cs
+++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Helpers/VaultHelpers.cs
@@ -13,6 +13,9 @@
// ----------------------------------------------------------------------------------
using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
using ClientModel = Microsoft.Azure.Management.BackupServices.Models;
using CmdletModel = Microsoft.Azure.Commands.AzureBackup.Models;
@@ -50,5 +53,76 @@ public static string GetResourceGroup(string vaultId)
string[] tokens = vaultId.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
return tokens[3];
}
+
+ ///
+ /// Extension to convert enumerable Hashtable into a dictionary
+ ///
+ ///
+ ///
+ public static Dictionary ConvertToDictionary(this Hashtable[] tags)
+ {
+ return tags == null
+ ? null
+ : tags
+ .CoalesceEnumerable()
+ .Select(hashTable => hashTable.OfType()
+ .ToDictionary(kvp => kvp.Key.ToString(), kvp => kvp.Value))
+ .Where(tagDictionary => tagDictionary.ContainsKey("Name"))
+ .Select(tagDictionary => Tuple
+ .Create(
+ tagDictionary["Name"].ToString(),
+ tagDictionary.ContainsKey("Value") ? tagDictionary["Value"].ToString() : string.Empty))
+ .Distinct(kvp => kvp.Item1)
+ .ToDictionary(kvp => kvp.Item1, kvp => kvp.Item2);
+ }
+
+ ///
+ /// Extension to coalesce enumerable
+ ///
+ /// Enumerable type
+ /// Enumerable
+ ///
+ public static IEnumerable CoalesceEnumerable(this IEnumerable source)
+ {
+ return source ?? Enumerable.Empty();
+ }
+
+ ///
+ /// Extension to remove duplicates from enumerable based on a provided key selector
+ ///
+ /// Enumerable type
+ /// Type of key
+ /// Input enumerable to remove duplicates from
+ /// Lambda to select key
+ ///
+ public static IEnumerable Distinct(this IEnumerable source, Func keySelector)
+ {
+ var set = new Dictionary(EqualityComparer.Default);
+ foreach (TSource element in source)
+ {
+ TSource value;
+ var key = keySelector(element);
+ if (!set.TryGetValue(key, out value))
+ {
+ yield return element;
+ }
+ else
+ {
+ set[key] = value;
+ }
+ }
+ }
+
+ ///
+ /// Extension to convert dictionary to hashtable enumerable
+ ///
+ ///
+ ///
+ public static Hashtable[] GetTagsHashtables(this IDictionary tags)
+ {
+ return tags == null
+ ? null
+ : tags.Select(kvp => new Hashtable { { "Name", kvp.Key }, { "Value", kvp.Value } }).ToArray();
+ }
}
}
diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzurePSBackupVault.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzurePSBackupVault.cs
index a86ec7bc4aeb..d57047ba15ee 100644
--- a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzurePSBackupVault.cs
+++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzurePSBackupVault.cs
@@ -30,7 +30,8 @@ public class AzureRMBackupVault
public string Region { get; set; }
- // public Hashtable[] Tags { get; protected set; }
+ // TODO: Add support for tags
+ //public Hashtable[] Tags { get; set; }
public string Storage { get; set; }
diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Resources/Microsoft.Azure.Management.BackupServicesManagement.dll b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Resources/Microsoft.Azure.Management.BackupServicesManagement.dll
deleted file mode 100644
index dbee840b00a5..000000000000
Binary files a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Resources/Microsoft.Azure.Management.BackupServicesManagement.dll and /dev/null differ
diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/packages.config b/src/ResourceManager/AzureBackup/Commands.AzureBackup/packages.config
index 2d0042531dd2..4f83b6260f45 100644
--- a/src/ResourceManager/AzureBackup/Commands.AzureBackup/packages.config
+++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/packages.config
@@ -4,7 +4,7 @@
-
+