Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error CS1503 Argument 2: cannot convert from 'System.IO.FileMode' to 'Microsoft.WindowsAzure.Storage.AccessCondition' #103

Closed
rhpoon opened this issue Feb 6, 2018 · 2 comments

Comments

@rhpoon
Copy link

rhpoon commented Feb 6, 2018

Hi I am trying to access Azure Blob from the sample C# Console Application (for Retrain Azure Machine Learning Models Programmatically) and ran into this problem.

I am wondering if this is caused by the version of Azure Portal (maybe the codes are meant to access the classic Azure portal as indicated by Microsoft DOCs), or is caused by the package Microsoft.WindowsAzure.Storage (referenced to :\Users\user\source\repos\ConsoleApp1\packages\WindowsAzure.Storage.8.7.0\lib\net45\Microsoft.WindowsAzure.Storage.dll)

I have installed both: PM> Install-Package Microsoft.AspNet.WebApi.Client and Install-Package WindowsAzure.Storage -Version 8.7.0

static void UploadFileToBlob(string inputFileLocation, string inputBlobName, string storageContainerName, string storageConnectionString)
{
// Make sure the file exists
if (!File.Exists(inputFileLocation))
{
throw new FileNotFoundException(
string.Format(
CultureInfo.InvariantCulture,
"File {0} doesn't exist on local computer.",
inputFileLocation));
}

        Console.WriteLine("Uploading the input to blob storage...");

        var blobClient = CloudStorageAccount.Parse(storageConnectionString).CreateCloudBlobClient();
        var container = blobClient.GetContainerReference(storageContainerName);
        container.CreateIfNotExists();
        var blob = container.GetBlockBlobReference(inputBlobName);
        blob.UploadFromFile(inputFileLocation, FileMode.Open);
    }

Severity Code Description Project File Line Suppression State
Error CS1503 Argument 2: cannot convert from 'System.IO.FileMode' to 'Microsoft.WindowsAzure.Storage.AccessCondition' ConsoleApp1 C:\Users\user\source\repos\ConsoleApp1\ConsoleApp1\Program.cs 116 Active

Any help or clues appreciated.

@HowardWolosky
Copy link
Member

This doesn't appear to be a StoreBroker question.

This project is simply a consumer of Azure Data Movement, like yourself. If you have a question about using it, you may want to ask on the actual project page.

@HowardWolosky
Copy link
Member

That being said, it looks like you're using a mismatched version of the package. If you look at our usage, here are the versions we use:

  $nugetPackageName = "WindowsAzure.Storage"
  $nugetPackageVersion = "8.1.1"
  $assemblyPackageTailDir = "WindowsAzure.Storage.8.1.1\lib\net45\"
  $assemblyName = "Microsoft.WindowsAzure.Storage.dll"

  $nugetPackageName = "Microsoft.Azure.Storage.DataMovement"
  $nugetPackageVersion = "0.5.1"
  $assemblyPackageTailDir = "Microsoft.Azure.Storage.DataMovement.0.5.1\lib\net45\"
  $assemblyName = "Microsoft.WindowsAzure.Storage.DataMovement.dll"

And then the second parameter to your upload method would be the blob URL, not the file mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants