Search code examples
visual-studioazure-files

How do I resolve conflicts between these two namespaces?


In my code I'm using both these two namespaces and all works fine until I try to use the CopyStatus that exists in both. This piece of code works just fine in LINQPad5 with the exact same namespaces, however in VS2019 I'm finding that it cannot fine CopyState in the Storage.File class.

using Microsoft.WindowsAzure.Storage.Blob;
using Microsoft.WindowsAzure.Storage.File;

Code from LINQPad5

CloudFile file = share.GetRootDirectoryReference().GetFileReference(myfile);

string blobSas = blob.GetSharedAccessSignature(new SharedAccessBlobPolicy()
{
    Permissions = SharedAccessBlobPermissions.Read,
    SharedAccessExpiryTime = DateTime.UtcNow.AddHours(24)
});
Uri blobSasUri = new Uri(blob.StorageUri.PrimaryUri.ToString() + blobSas);
file.StartCopy(blobSasUri);
file.FetchAttributes();

int count=0;
while (file.CopyState.Status != Microsoft.WindowsAzure.Storage.File.CopyStatus.Success)
{
    Thread.Sleep(1000);
    Console.WriteLine(@"{0} - Sleep one second", count++.ToString());
    file.FetchAttributes();
}

But this (almost) same code does not work in VS2109.

enter image description here

file.StartCopy(bpe.BlobUri);
file.FetchAttributes();
while (file.CopyState.Status != Microsoft.WindowsAzure.Storage.File.CopyStatus.Success)

Picture showing Microsoft.WindowsAzure.Storage.File.CopyStatus does not exist.

enter image description here


Solution

  • This issue could be mainly caused by a missing nugget from VS 2019, I'd recommend installing the latest WindowsAzure.storage Nugget found here Restart VS then retry again.