diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/VaultCredentials/GetAzureBackupVaultCredentials.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/VaultCredentials/GetAzureBackupVaultCredentials.cs
index c3169e239210..70f4908cec92 100644
--- a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/VaultCredentials/GetAzureBackupVaultCredentials.cs
+++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/VaultCredentials/GetAzureBackupVaultCredentials.cs
@@ -45,8 +45,11 @@ public override void ExecuteCmdlet()
ExecutionBlock(() =>
{
- WriteVerbose(string.Format("Profile == null : {0}", (Profile == null).ToString()));
- WriteVerbose(string.Format("Profile.DefaultSubscription == null : {0}", (Profile.DefaultSubscription == null).ToString()));
+ if (!Directory.Exists(TargetLocation))
+ {
+ throw new ArgumentException("The target location provided is not a directory. Please provide a directory.");
+ }
+
string subscriptionId = Profile.DefaultSubscription.Id.ToString();
string resourceType = "resourceType";
string displayName = subscriptionId + "_" + ResourceGroupName + "_" + ResourceName;
@@ -62,7 +65,6 @@ public override void ExecuteCmdlet()
DateTime.UtcNow.AddHours(this.GetCertificateExpiryInHours()));
AcsNamespace acsNamespace = new AcsNamespace();
-
string channelIntegrityKey = string.Empty;
try
{
@@ -80,8 +82,16 @@ public override void ExecuteCmdlet()
string vaultCredsFileContent = GenerateVaultCreds(cert, subscriptionId, resourceType, acsNamespace);
// prepare for download
- string fileName = string.Format("{0}_{1}.VaultCredentials", displayName, DateTime.UtcNow.ToLongDateString());
- string filePath = Path.Combine(Path.GetDirectoryName(TargetLocation), fileName);
+ string fileName = string.Format("{0}_{1}.VaultCredentials", displayName, DateTime.UtcNow.ToString("yyyy-dd-M--HH-mm-ss"));
+ string directoryPath = Path.GetDirectoryName(TargetLocation);
+ if (directoryPath == null)
+ {
+ // TargetLocation is a root path
+ directoryPath = TargetLocation;
+ }
+ string filePath = Path.Combine(directoryPath, fileName);
+ WriteVerbose(string.Format("Saving Vault Credentials to file : {0}", filePath));
+
File.WriteAllBytes(filePath, Encoding.UTF8.GetBytes(vaultCredsFileContent));
// Output filename back to user
diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Commands.AzureBackup.csproj b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Commands.AzureBackup.csproj
index ecc3662b0c45..9368865fe23e 100644
--- a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Commands.AzureBackup.csproj
+++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Commands.AzureBackup.csproj
@@ -43,6 +43,14 @@
false
+
+ False
+ Resources\BackupManagementInterface.dll
+
+
+ False
+ Resources\BMSCommonInterface.dll
+
..\..\..\packages\Hyak.Common.1.0.2\lib\portable-net403+win+wpa81\Hyak.Common.dll
@@ -116,6 +124,7 @@
+
@@ -170,6 +179,8 @@
+
+