Skip to content

Commit 03afff0

Browse files
author
Samuel Anudeep
committed
Merge pull request #17 from MabOneSdk/anudeeb
DownloadVaultCredentials
2 parents d3cf619 + cf7435b commit 03afff0

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/VaultCredentials/GetAzureBackupVaultCredentials.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ public override void ExecuteCmdlet()
4545

4646
ExecutionBlock(() =>
4747
{
48-
WriteVerbose(string.Format("Profile == null : {0}", (Profile == null).ToString()));
49-
WriteVerbose(string.Format("Profile.DefaultSubscription == null : {0}", (Profile.DefaultSubscription == null).ToString()));
48+
if (!Directory.Exists(TargetLocation))
49+
{
50+
throw new ArgumentException("The target location provided is not a directory. Please provide a directory.");
51+
}
52+
5053
string subscriptionId = Profile.DefaultSubscription.Id.ToString();
5154
string resourceType = "resourceType";
5255
string displayName = subscriptionId + "_" + ResourceGroupName + "_" + ResourceName;
@@ -62,7 +65,6 @@ public override void ExecuteCmdlet()
6265
DateTime.UtcNow.AddHours(this.GetCertificateExpiryInHours()));
6366

6467
AcsNamespace acsNamespace = new AcsNamespace();
65-
6668
string channelIntegrityKey = string.Empty;
6769
try
6870
{
@@ -80,8 +82,16 @@ public override void ExecuteCmdlet()
8082
string vaultCredsFileContent = GenerateVaultCreds(cert, subscriptionId, resourceType, acsNamespace);
8183

8284
// prepare for download
83-
string fileName = string.Format("{0}_{1}.VaultCredentials", displayName, DateTime.UtcNow.ToLongDateString());
84-
string filePath = Path.Combine(Path.GetDirectoryName(TargetLocation), fileName);
85+
string fileName = string.Format("{0}_{1}.VaultCredentials", displayName, DateTime.UtcNow.ToString("yyyy-dd-M--HH-mm-ss"));
86+
string directoryPath = Path.GetDirectoryName(TargetLocation);
87+
if (directoryPath == null)
88+
{
89+
// TargetLocation is a root path
90+
directoryPath = TargetLocation;
91+
}
92+
string filePath = Path.Combine(directoryPath, fileName);
93+
WriteVerbose(string.Format("Saving Vault Credentials to file : {0}", filePath));
94+
8595
File.WriteAllBytes(filePath, Encoding.UTF8.GetBytes(vaultCredsFileContent));
8696

8797
// Output filename back to user

src/ResourceManager/AzureBackup/Commands.AzureBackup/Commands.AzureBackup.csproj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@
4343
<Prefer32Bit>false</Prefer32Bit>
4444
</PropertyGroup>
4545
<ItemGroup>
46+
<Reference Include="BackupManagementInterface, Version=1.0.523.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
47+
<SpecificVersion>False</SpecificVersion>
48+
<HintPath>Resources\BackupManagementInterface.dll</HintPath>
49+
</Reference>
50+
<Reference Include="BMSCommonInterface, Version=1.0.523.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
51+
<SpecificVersion>False</SpecificVersion>
52+
<HintPath>Resources\BMSCommonInterface.dll</HintPath>
53+
</Reference>
4654
<Reference Include="Hyak.Common">
4755
<HintPath>..\..\..\packages\Hyak.Common.1.0.2\lib\portable-net403+win+wpa81\Hyak.Common.dll</HintPath>
4856
</Reference>
@@ -116,6 +124,7 @@
116124
<Reference Include="System.Xml" />
117125
</ItemGroup>
118126
<ItemGroup>
127+
<Compile Include="AzureBackupContainerCmdletBase.cs" />
119128
<Compile Include="AzureBackupDSCmdletBase.cs" />
120129
<Compile Include="AzureBackupVaultCmdletBase.cs" />
121130
<Compile Include="AzureBackupCmdletBase.cs" />
@@ -170,6 +179,8 @@
170179
</EmbeddedResource>
171180
</ItemGroup>
172181
<ItemGroup>
182+
<Content Include="Resources\BackupManagementInterface.dll" />
183+
<Content Include="Resources\BMSCommonInterface.dll" />
173184
<Content Include="Resources\Microsoft.WindowsAzure.Management.Common.dll" />
174185
<Content Include="Resources\Security.Cryptography.dll" />
175186
</ItemGroup>

0 commit comments

Comments
 (0)