Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
23cf78b
Update storage management sdk.
EmmaZhu Aug 7, 2015
b99cc81
Resolve StorageAccount reference build error.
EmmaZhu Aug 10, 2015
f5f5343
Fix a build error.
EmmaZhu Aug 10, 2015
cc2386c
Add cmdlets to check storage account name availability and get storag…
EmmaZhu Aug 10, 2015
c9da0ce
"Name" parameter of Get-AzureStorageAccountAvailability should be man…
EmmaZhu Aug 21, 2015
0d4a22e
Merge branch 'dev' of https://github.com/wastoresh/azure-powershell i…
EmmaZhu Aug 25, 2015
59da5ac
Merge branch 'dev' of https://github.com/Azure/azure-powershell into SRP
EmmaZhu Aug 27, 2015
3dd50ae
[PSH]Adopt SRP GA SDK..
EmmaZhu Sep 17, 2015
90a83c1
Merge branch 'dev' of https://github.com/wastoresh/azure-powershell i…
EmmaZhu Sep 21, 2015
e56f016
Change new SRP cmdlets name to add RM prefix and add help info for them.
EmmaZhu Sep 21, 2015
0069419
Refine SRP cmdlets help info.
EmmaZhu Sep 22, 2015
2427c35
Merge branch 'dev' of https://github.com/wastoresh/azure-powershell i…
EmmaZhu Sep 25, 2015
46c9ba6
Change storage management cmdlet name to make it meet the RM cmdlets …
EmmaZhu Sep 29, 2015
7c16b51
Merge branch 'dev' of https://github.com/wastoresh/azure-powershell i…
EmmaZhu Oct 10, 2015
ab945bc
Update SRP management SDK to the latest.
EmmaZhu Oct 10, 2015
3ede32d
Fix build issues.
EmmaZhu Oct 12, 2015
0554a0d
Fix build issue.
EmmaZhu Oct 12, 2015
1f0bbe3
Change cmdlets Get-AzureStorageFile to get one file/directory when Pa…
EmmaZhu Oct 16, 2015
f04fd80
Update to windowsAzure.Storage 6.0.0
EmmaZhu Oct 20, 2015
6f0650c
Merge branch 'dev' of https://github.com/Azure/azure-powershell into …
EmmaZhu Oct 21, 2015
70af047
Publish service manament first.
EmmaZhu Oct 21, 2015
8204510
Resolve a build installer failure.
EmmaZhu Oct 21, 2015
5702c1d
RDTask 4209170:[PSH]Support new APIs for file analytic settings
Oct 20, 2015
22f6298
Merge branch 'sprint55' of https://github.com/wastoresh/azure-powersh…
Oct 21, 2015
401fcdc
Merge branch 'dev' of https://github.com/Azure/azure-powershell into …
EmmaZhu Oct 23, 2015
3e040c8
BUT:4994669[PSH]Fix the bug that it cannot get file endpoint from cur…
EmmaZhu Oct 23, 2015
5812cee
[PSH]Fix bug that the cmdlet "Get-AzureStorageFile" cannot handle a p…
EmmaZhu Oct 26, 2015
a56c053
Merge branch 'dev' of https://github.com/Azure/azure-powershell into …
EmmaZhu Oct 27, 2015
2c1d020
Fix issue of cannot find file endpoint with current storage account s…
EmmaZhu Oct 28, 2015
c03692c
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
EmmaZhu Oct 28, 2015
941123f
Fix test issue in compute unit test.
EmmaZhu Oct 28, 2015
9a73eb2
Rerecord compute test sessions.
EmmaZhu Oct 29, 2015
9e28688
Merge branch 'sprint55' of https://github.com/wastoresh/azure-powersh…
EmmaZhu Oct 29, 2015
b0d6ef7
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
EmmaZhu Oct 29, 2015
4f90490
Rerecord for compute test cases.
EmmaZhu Oct 29, 2015
315ec40
Disable the VMDynamicTests temporarily to pass CIT
yaxia Oct 30, 2015
fc3283d
Disable more compute case for the OutOfMemory exception
yaxia Oct 30, 2015
705826e
Merge branch 'release-1.0.0' of https://github.com/Azure/azure-powers…
EmmaZhu Oct 31, 2015
78cccc3
Resolve compute test issues.
EmmaZhu Oct 31, 2015
fc90a77
Roll back change in the build target.
EmmaZhu Oct 31, 2015
992f655
Resolve test issues.
EmmaZhu Nov 1, 2015
545d368
Resolve test issues.
EmmaZhu Nov 1, 2015
375cfcf
Merge branch 'release-1.0.0' of https://github.com/Azure/azure-powers…
EmmaZhu Nov 1, 2015
98e3d50
Resolve PR comments.
EmmaZhu Nov 2, 2015
3de046f
Remove skipping on cases which doesn't cause the OOM issue.
EmmaZhu Nov 2, 2015
c179afb
Downgrade xscl in HDInsight to 3.0.3
EmmaZhu Nov 2, 2015
bdadde4
Merge branch 'release-1.0.0' of https://github.com/Azure/azure-powers…
EmmaZhu Nov 3, 2015
ac641f7
Roll back some project which doesn't need to upgrade to xscl6.0
EmmaZhu Nov 3, 2015
2d92900
Revert some unnecessary changes.
EmmaZhu Nov 3, 2015
f287523
Add storage data plane projects back to storage solution in ARM.
EmmaZhu Nov 3, 2015
22f1554
Rerecord for sql test issue. The account name with suffix 1029 has be…
EmmaZhu Nov 3, 2015
830f961
Resolve some unit test issues.
EmmaZhu Nov 3, 2015
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 @@ -67,9 +67,9 @@
<HintPath>..\..\packages\Microsoft.Azure.KeyVault.Core.1.0.0\lib\net40\Microsoft.Azure.KeyVault.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Storage, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Azure.Management.Storage.2.4.0-preview\lib\net40\Microsoft.Azure.Management.Storage.dll</HintPath>
<Private>True</Private>
<Reference Include="Microsoft.Azure.Management.Storage, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.Azure.Management.Storage.3.0.0\lib\net40\Microsoft.Azure.Management.Storage.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down Expand Up @@ -118,9 +118,9 @@
<Reference Include="Microsoft.WindowsAzure.Management.Storage">
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.Storage.5.1.1\lib\net40\Microsoft.WindowsAzure.Management.Storage.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Storage, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Reference Include="Microsoft.WindowsAzure.Storage, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\WindowsAzure.Storage.5.0.0\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
<HintPath>..\..\packages\WindowsAzure.Storage.6.0.0\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
9 changes: 6 additions & 3 deletions src/Common/Commands.Common.Storage/StorageUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,14 @@ public static CloudStorageAccount GenerateCloudStorageAccount(Arm.IStorageManage
Uri blobEndpoint = storageServiceResponse.StorageAccount.PrimaryEndpoints.Blob;
Uri queueEndpoint = storageServiceResponse.StorageAccount.PrimaryEndpoints.Queue;
Uri tableEndpoint = storageServiceResponse.StorageAccount.PrimaryEndpoints.Table;
Uri fileEndpoint = storageServiceResponse.StorageAccount.PrimaryEndpoints.File;

return new CloudStorageAccount(
GenerateStorageCredentials(storageClient, resourceGroupName, accountName),
blobEndpoint,
queueEndpoint,
tableEndpoint, null);
tableEndpoint,
fileEndpoint);
}
else
{
Expand All @@ -61,8 +64,8 @@ public static CloudStorageAccount GenerateCloudStorageAccount(Arm.IStorageManage
Convert.ToBase64String(Encoding.UTF8.GetBytes(Guid.NewGuid().ToString()))),
new Uri(string.Format("https://{0}.blob.core.windows.net", accountName)),
new Uri(string.Format("https://{0}.queue.core.windows.net", accountName)),
new Uri(string.Format("https://{0}.table.core.windows.net", accountName)),
null);
new Uri(string.Format("https://{0}.table.core.windows.net", accountName)),
new Uri(string.Format("https://{0}.file.core.windows.net", accountName)));
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Common/Commands.Common.Storage/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Resources" version="2.18.7-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Storage" version="2.4.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Storage" version="3.0.0" targetFramework="net45" />
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net45" />
Expand All @@ -22,5 +22,5 @@
<package id="Microsoft.WindowsAzure.Management.Storage" version="5.1.1" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
<package id="System.Spatial" version="5.6.4" targetFramework="net45" />
<package id="WindowsAzure.Storage" version="5.0.0" targetFramework="net45" />
<package id="WindowsAzure.Storage" version="6.0.0" targetFramework="net45" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.ConfigurationManager.2.0.3\lib\net40\Microsoft.WindowsAzure.Configuration.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Storage">
<HintPath>..\..\..\packages\WindowsAzure.Storage.5.0.0\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
<HintPath>..\..\..\packages\WindowsAzure.Storage.6.0.0\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
<package id="System.Spatial" version="5.6.4" targetFramework="net45" />
<package id="WindowsAzure.Storage" version="5.0.0" targetFramework="net45" />
<package id="WindowsAzure.Storage" version="6.0.0" targetFramework="net45" />
<package id="xunit.runner.visualstudio" version="2.1.0-beta4-build1109" targetFramework="net45" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.ConfigurationManager.2.0.3\lib\net40\Microsoft.WindowsAzure.Configuration.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Storage">
<HintPath>..\..\..\packages\WindowsAzure.Storage.5.0.0\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
<HintPath>..\..\..\packages\WindowsAzure.Storage.6.0.0\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
<package id="System.Spatial" version="5.6.4" targetFramework="net45" />
<package id="WindowsAzure.Storage" version="5.0.0" targetFramework="net45" />
<package id="WindowsAzure.Storage" version="6.0.0" targetFramework="net45" />
<package id="xunit.runner.visualstudio" version="2.1.0-beta4-build1109" targetFramework="net45" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Storage">
<HintPath>..\..\..\packages\WindowsAzure.Storage.5.0.0\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
<HintPath>..\..\..\packages\WindowsAzure.Storage.6.0.0\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Storage.DataMovement, Version=2.4.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,33 +76,34 @@ public void GetFileFromSubDirectoryTest_UsingShareObjectWithPath()
{
var share = this.MockChannel.GetShareReference(ShareName);
var dir = share.GetRootDirectoryReference().GetDirectoryReference("dir");
var listItems = Enumerable.Range(0, 10).Select(x => dir.GetFileReference(string.Format("file{0}", x))).Cast<IListFileItem>()
.Concat(Enumerable.Range(0, 5).Select(x => dir.GetDirectoryReference(string.Format("dir{0}", x)))).ToArray();

this.ListFilesAndAssertResults(
() => this.CmdletInstance.RunCmdlet(
Constants.ShareParameterSetName,
new KeyValuePair<string, object>("Share", share),
new KeyValuePair<string, object>("Path", dir.Name)),
listItems,
dir);
this.MockChannel.SetsAvailableDirectories(dir.Name);

this.CmdletInstance.RunCmdlet(
Constants.ShareNameParameterSetName,
new KeyValuePair<string, object>("ShareName", ShareName),
new KeyValuePair<string, object>("Path", dir.Name));

List<IListFileItem> fileList = new List<IListFileItem>();
fileList.Add(dir);
this.MockCmdRunTime.OutputPipeline.AssertListFileItems(fileList);
}

[TestMethod]
public void GetFileFromSubDirectoryTest_UsingShareNameWithPath()
{
var share = this.MockChannel.GetShareReference(ShareName);
var dir = share.GetRootDirectoryReference().GetDirectoryReference("dir");
var listItems = Enumerable.Range(0, 10).Select(x => dir.GetFileReference(string.Format("file{0}", x))).Cast<IListFileItem>()
.Concat(Enumerable.Range(0, 5).Select(x => dir.GetDirectoryReference(string.Format("dir{0}", x)))).ToArray();
this.MockChannel.SetsAvailableDirectories(dir.Name);

this.ListFilesAndAssertResults(
() => this.CmdletInstance.RunCmdlet(
this.CmdletInstance.RunCmdlet(
Constants.ShareNameParameterSetName,
new KeyValuePair<string, object>("ShareName", ShareName),
new KeyValuePair<string, object>("Path", dir.Name)),
listItems,
dir);
new KeyValuePair<string, object>("Path", dir.Name));

List<IListFileItem> fileList = new List<IListFileItem>();
fileList.Add(dir);
this.MockCmdRunTime.OutputPipeline.AssertListFileItems(fileList);
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,26 @@ public void SetSharePermissions(CloudFileShare share, FileSharePermissions permi

public Task FetchFileAttributesAsync(CloudFile file, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken token)
{
throw new NotImplementedException();
if (this.availableDirectoryNames.Contains(file.Name))
{
return TaskEx.FromResult(true);
}
else
{
throw new MockupException("FileNotFound");
}
}

public Task FetchDirectoryAttributesAsync(CloudFileDirectory directory, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
{
if (this.availableDirectoryNames.Contains(directory.Name))
{
return TaskEx.FromResult(true);
}
else
{
throw new MockupException("DirectoryNotFound");
}
}

public Task AbortCopyAsync(CloudFile file, string copyId, AccessCondition accessCondition, FileRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken)
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Storage/Commands.Storage.Test/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<package id="Microsoft.WindowsAzure.Management" version="4.1.1" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
<package id="System.Spatial" version="5.6.4" targetFramework="net45" />
<package id="WindowsAzure.Storage" version="5.0.0" targetFramework="net45" />
<package id="WindowsAzure.Storage" version="6.0.0" targetFramework="net45" />
<package id="xunit.runner.visualstudio" version="2.1.0-beta4-build1109" targetFramework="net45" />
</packages>
4 changes: 2 additions & 2 deletions src/Common/Storage/Commands.Storage/Commands.Storage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@
<Reference Include="Microsoft.WindowsAzure.Management">
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Storage, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Reference Include="Microsoft.WindowsAzure.Storage, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\WindowsAzure.Storage.5.0.0\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
<HintPath>..\..\..\packages\WindowsAzure.Storage.6.0.0\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Storage.DataMovement">
<HintPath>..\..\..\lib\Microsoft.WindowsAzure.Storage.DataMovement.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ public GetAzureStorageServiceMetricsCommand()
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
public override void ExecuteCmdlet()
{
if (StorageServiceType.File == ServiceType)
{
throw new PSInvalidOperationException(Resources.FileNotSupportMetrics);
}

ServiceProperties serviceProperties = Channel.GetStorageServiceProperties(ServiceType, GetRequestOptions(ServiceType) , OperationContext);

switch (MetricsType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,6 @@ internal MetricsLevel GetMetricsLevel(string MetricsLevel)
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
public override void ExecuteCmdlet()
{
if (StorageServiceType.File == ServiceType)
{
throw new PSInvalidOperationException(Resources.FileNotSupportMetrics);
}

ServiceProperties currentServiceProperties = Channel.GetStorageServiceProperties(ServiceType, GetRequestOptions(ServiceType), OperationContext);
ServiceProperties serviceProperties = new ServiceProperties();
serviceProperties.Clean();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public virtual int? ConcurrentTaskCount
}
}

public T Channel
public T Channel
{
get;
set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ namespace Microsoft.WindowsAzure.Commands.Storage.File.Cmdlet
{
using System.Globalization;
using System.Management.Automation;
using System.Net;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.File;

[Cmdlet(VerbsCommon.Get, Constants.FileCmdletName, DefaultParameterSetName = Constants.ShareNameParameterSetName)]
Expand Down Expand Up @@ -49,13 +51,12 @@ public class GetAzureStorageFile : AzureStorageFileCmdletBase

[Parameter(
Position = 1,
HelpMessage = "Path to an existing directory.")]
HelpMessage = "Path to an existing file/directory.")]
public string Path { get; set; }

public override void ExecuteCmdlet()
{
CloudFileDirectory baseDirectory;
string[] subFolders = NamingUtil.ValidatePath(this.Path);
switch (this.ParameterSetName)
{
case Constants.DirectoryParameterSetName:
Expand All @@ -74,15 +75,65 @@ public override void ExecuteCmdlet()
throw new PSArgumentException(string.Format(CultureInfo.InvariantCulture, "Invalid parameter set name: {0}", this.ParameterSetName));
}

this.RunTask(async (taskId) =>
if (string.IsNullOrEmpty(this.Path))
{
await this.Channel.EnumerateFilesAndDirectoriesAsync(
baseDirectory.GetDirectoryReferenceByPath(subFolders),
item => this.OutputStream.WriteObject(taskId, item),
this.RequestOptions,
this.OperationContext,
this.CmdletCancellationToken);
});
this.RunTask(async (taskId) =>
{
await this.Channel.EnumerateFilesAndDirectoriesAsync(
baseDirectory,
item => this.OutputStream.WriteObject(taskId, item),
this.RequestOptions,
this.OperationContext,
this.CmdletCancellationToken);
});
}
else
{
this.RunTask(async (taskId) =>
{
bool foundAFolder = true;
string[] subfolders = NamingUtil.ValidatePath(this.Path);
CloudFileDirectory targetDir = baseDirectory.GetDirectoryReferenceByPath(subfolders);

try
{
await this.Channel.FetchDirectoryAttributesAsync(
targetDir,
null,
this.RequestOptions,
this.OperationContext,
this.CmdletCancellationToken);
}
catch (StorageException se)
{
if (null == se.RequestInformation
|| (int)HttpStatusCode.NotFound != se.RequestInformation.HttpStatusCode)
{
throw;
}

foundAFolder = false;
}

if (foundAFolder)
{
this.OutputStream.WriteObject(taskId, targetDir);
return;
}

string[] filePath = NamingUtil.ValidatePath(this.Path, true);
CloudFile targetFile = baseDirectory.GetFileReferenceByPath(filePath);

await this.Channel.FetchFileAttributesAsync(
targetFile,
null,
this.RequestOptions,
this.OperationContext,
this.CmdletCancellationToken);

this.OutputStream.WriteObject(taskId, targetFile);
});
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static CloudFileDirectory GetDirectoryReferenceByPath(this CloudFileDirec
currentDirectory = currentDirectory.GetDirectoryReference(subFolder);
}

return currentDirectory;
return new CloudFileDirectory(currentDirectory.Uri, currentDirectory.Share.ServiceClient.Credentials);
}

/// <summary>
Expand All @@ -71,7 +71,9 @@ public static CloudFile GetFileReferenceByPath(this CloudFileDirectory currentDi
currentDirectory = currentDirectory.GetDirectoryReference(path[i]);
}

return currentDirectory.GetFileReference(path.Last());
CloudFile file = currentDirectory.GetFileReference(path.Last());

return new CloudFile(file.Uri, file.Share.ServiceClient.Credentials);
}

/// <summary>
Expand Down
Loading