Azure / azure-storage-net-data-movement

Azure Storage Data Movement Library for .Net
MIT License
275 stars 132 forks source link

Unable to Execute UploadDirectoryAsync with Xamarin.Mac #227

Open wgwolanski opened 4 years ago

wgwolanski commented 4 years ago

Which service(blob, file) does this issue concern?

Uploading local files to a Blob instance

Which version of the SDK was used?

<package id="Microsoft.Azure.Storage.DataMovement" version="1.3.0" targetFramework="net48" />

On which platform were you using? (.Net Framework version or .Net Core version, and OS version)

Xamarin.Mac Full targeting .NET Framework 4.8 (possibly through Mono). I am using Xamarin.Mac Full as opposed to Modern for full Nuget support. I am developing and executing on a Mac using Visual Studio for Mac

How can the problem be reproduced? It'd be better if the code caused the problem can be shared.

I'm essentially trying to run the sample for uploading a local file directory to blob storage. The error happens after the await is called: `try { Task task = TransferManager.UploadDirectoryAsync(sourceDirPath, destDir, options, context, cancellationSource.Token);

                // Sleep for 1 seconds and cancel the transfer. 
                // It may fail to cancel the transfer if transfer is done in 1 second. If so, no file will be copied after resume.
                //Thread.Sleep(1000);
                //Console.WriteLine("Cancel the transfer.");
                //cancellationSource.Cancel();

                trasferStatus = await task;
            }
            catch (Exception e)
            {
                Console.WriteLine("The transfer is cancelled: {0}", e.Message);
            }`

What problem was encountered?

When this runs, I get this exception: System.AggregateException: One or more errors occurred. (GetFullPathNameW assembly:<unknown assembly> type:<unknown type> member:(null)) ---> System.EntryPointNotFoundException: GetFullPathNameW assembly:<unknown assembly> type:<unknown type> member:(null) at at (wrapper managed-to-native) Microsoft.Azure.Storage.DataMovement.Interop.NativeMethods.GetFullPathNameW(string,uint,System.Text.StringBuilder,System.Text.StringBuilder) at Microsoft.Azure.Storage.DataMovement.LongPath.GetFullPath (System.String path) [0x00014] in <cce3d5ce8f3f47398086353a536e490d>:0 at Microsoft.Azure.Storage.DataMovement.LongPath.ToUncPath (System.String path) [0x00017] in <cce3d5ce8f3f47398086353a536e490d>:0 at Microsoft.Azure.Storage.DataMovement.TransferEnumerators.FileEnumerator+<EnumerateLocation>d__8.MoveNext () [0x00083] in <cce3d5ce8f3f47398086353a536e490d>:0 at Microsoft.Azure.Storage.DataMovement.FlatDirectoryTransfer.ListNewTransfers (System.Threading.CancellationToken cancellationToken) [0x00068] in <cce3d5ce8f3f47398086353a536e490d>:0 at Microsoft.Azure.Storage.DataMovement.FlatDirectoryTransfer+<>c__DisplayClass17_0.<ExecuteInternalAsync>b__0 () [0x00000] in <cce3d5ce8f3f47398086353a536e490d>:0 at System.Threading.Tasks.Task.InnerInvoke () [0x0000f] in /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/src/Xamarin.Mac/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:2476 at System.Threading.Tasks.Task.Execute () [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/src/Xamarin.Mac/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:2319 at Microsoft.Azure.Storage.DataMovement.FlatDirectoryTransfer.ExecuteInternalAsync (Microsoft.Azure.Storage.DataMovement.TransferScheduler scheduler, System.Threading.CancellationToken cancellationToken) [0x00133] in <cce3d5ce8f3f47398086353a536e490d>:0 at Microsoft.Azure.Storage.DataMovement.FlatDirectoryTransfer.ExecuteInternalAsync (Microsoft.Azure.Storage.DataMovement.TransferScheduler scheduler, System.Threading.CancellationToken cancellationToken) [0x001d1] in <cce3d5ce8f3f47398086353a536e490d>:0 at Microsoft.Azure.Storage.DataMovement.DirectoryTransfer.ExecuteAsync (Microsoft.Azure.Storage.DataMovement.TransferScheduler scheduler, System.Threading.CancellationToken cancellationToken) [0x000bd] in <cce3d5ce8f3f47398086353a536e490d>:0 at Microsoft.Azure.Storage.DataMovement.TransferManager.DoTransfer (Microsoft.Azure.Storage.DataMovement.Transfer transfer, Microsoft.Azure.Storage.DataMovement.TransferContext transferContext, System.Threading.CancellationToken cancellationToken) [0x000c2] in <cce3d5ce8f3f47398086353a536e490d>:0 at Microsoft.Azure.Storage.DataMovement.TransferManager.UploadDirectoryInternalAsync (Microsoft.Azure.Storage.DataMovement.TransferLocation sourceLocation, Microsoft.Azure.Storage.DataMovement.TransferLocation destLocation, Microsoft.Azure.Storage.DataMovement.TransferEnumerators.ITransferEnumerator sourceEnumerator, Microsoft.Azure.Storage.DataMovement.UploadDirectoryOptions options, Microsoft.Azure.Storage.DataMovement.DirectoryTransferContext context, System.Threading.CancellationToken cancellationToken) [0x00160] in <cce3d5ce8f3f47398086353a536e490d>:0 at <Project-Name> () [0x00397]

Have you found a mitigation/solution?

No solution, but after looking in to it I noticed this: https://github.com/Azure/azure-storage-net-data-movement/blob/4b2918bdcb335657b8d427aadb581f89b8db9bed/lib/LongPathFileStream.cs#L134

The library seems to be checking if its DOTNET5_4 and if not assumed I'm using windows and uses some windows specific functions. Normally this would be a safe assumption, but Xamarin.Mac seems to be circumventing it since it wraps .net framework 4.8. Any information of recommendation would be very helpful! Thanks

jiacfan commented 4 years ago

Thanks for reaching us, @wgwolanski. Your investigation result is correct and the library hasn't tested this matrix. We'll track this requirement. +@EmmaZhu for visbility.