Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

copy from internal uri with storage context

  • Loading branch information...
commit c49919f752b8c5b4369ad85d5e8b3206ea9db76a 1 parent 9317bd3
@xmbms xmbms authored
View
28 WindowsAzurePowershell/src/Management.Storage/Blob/Cmdlet/StartCopyAzureStorageBlob.cs
@@ -98,11 +98,11 @@ public string SrcContainer
ParameterSetName = ContainerPipelineParameterSet)]
public string DestContainer { get; set; }
- [Parameter(HelpMessage = "Destination blob name", Mandatory = false,
- ParameterSetName = NameParameterSet)]
[Parameter(HelpMessage = "Destination blob name", Mandatory = true,
ParameterSetName = UriParameterSet)]
[Parameter(HelpMessage = "Destination blob name", Mandatory = false,
+ ParameterSetName = NameParameterSet)]
+ [Parameter(HelpMessage = "Destination blob name", Mandatory = false,
ParameterSetName = SrcBlobParameterSet)]
[Parameter(HelpMessage = "Destination container name", Mandatory = false,
ParameterSetName = ContainerPipelineParameterSet)]
@@ -121,6 +121,7 @@ public string SrcContainer
ValueFromPipelineByPropertyName = true, ParameterSetName = DestBlobPipelineParameterSet)]
[Parameter(HelpMessage = "Source Azure Storage Context Object",
ValueFromPipelineByPropertyName = true, ParameterSetName = ContainerPipelineParameterSet)]
+ [Parameter(HelpMessage = "Source Azure Storage Context Object", ParameterSetName = UriParameterSet)]
public override AzureStorageContext Context { get; set; }
[Parameter(HelpMessage = "Destination Storage context object", Mandatory = false)]
@@ -214,7 +215,7 @@ public override void ExecuteCmdlet()
break;
case UriParameterSet:
- destinationBlob = StartCopyBlob(SrcUri, DestContainer, DestBlob);
+ destinationBlob = StartCopyBlob(SrcUri, DestContainer, DestBlob, Context);
break;
case SrcBlobParameterSet:
@@ -274,10 +275,27 @@ private ICloudBlob StartCopyBlob(ICloudBlob srcICloudBlob, string destContainer,
/// <param name="destContainer">Destinaion container name</param>
/// <param name="destBlobName">Destination blob name</param>
/// <returns>Destination ICloudBlob object</returns>
- private ICloudBlob StartCopyBlob(string srcUri, string destContainer, string destBlobName)
+ private ICloudBlob StartCopyBlob(string srcUri, string destContainer, string destBlobName, AzureStorageContext context)
{
+ if (context != null)
+ {
+ Uri sourceUri = new Uri(srcUri);
+ Uri contextUri = new Uri(context.BlobEndPoint);
+
+ if (sourceUri.Host.ToLower() == contextUri.Host.ToLower())
+ {
+ CloudBlobClient blobClient = context.StorageAccount.CreateCloudBlobClient();
+ ICloudBlob blobReference = blobClient.GetBlobReferenceFromServer(sourceUri);
+ return StartCopyBlob(blobReference, destContainer, destBlobName);
+ }
+ else
+ {
+ WriteVerbose(String.Format(Resources.StartCopySourceContextMismatch, srcUri, context.BlobEndPoint));
+ }
+ }
+
CloudBlobContainer container = destChannel.GetContainerReference(destContainer);
- return StartCopyInTransferManager(new Uri(srcUri), container, destBlobName);
+ return StartCopyInTransferManager(new Uri(srcUri), container, destBlobName);
}
/// <summary>
View
11 WindowsAzurePowershell/src/Management.Storage/Resources.Designer.cs
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:4.0.30319.18033
+// Runtime Version:4.0.30319.18010
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -961,6 +961,15 @@ internal class Resources {
}
/// <summary>
+ /// Looks up a localized string similar to Ignore mismatch source storage context.. The source uri is {0}, the end point is {1}..
+ /// </summary>
+ internal static string StartCopySourceContextMismatch {
+ get {
+ return ResourceManager.GetString("StartCopySourceContextMismatch", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Start to download blob &apos;{0}&apos; to &apos;{1}&apos;..
/// </summary>
internal static string StartDownloadBlob {
View
4 WindowsAzurePowershell/src/Management.Storage/Resources.resx
@@ -537,4 +537,8 @@ Successful: {1}.
Failed: {2}.</value>
<comment>0 for total task count, 1 for successful count, 2 for failed count</comment>
</data>
+ <data name="StartCopySourceContextMismatch" xml:space="preserve">
+ <value>Ignore mismatch source storage context.. The source uri is {0}, the end point is {1}.</value>
+ <comment>0 for source uri, 1 for blob end point.</comment>
+ </data>
</root>
Please sign in to comment.
Something went wrong with that request. Please try again.