none
"URI format not supported" - Web service accessing Blob Storage

    Question

  • Hello,

    I am trying to create a console app that takes Blob storage file as input to a web service that I published using Azure Machine Learning Studio.

    I successfully created a console app a while back that does the same thing, but takes a locally stored CSV file as input instead of looking into Blob storage.

    I am getting this error when I run my program: 

    Exception:Thrown: "URI formats are not supported." (System.ArgumentException)

    The error is thrown at the last line of this code:

    const string StorageAccountName = "mlxdevopsmlpoc"; // Replace this with your Azure Storage Account name

    const string StorageContainerName = "hddefault"; // Replace this with your Azure Storage Container name
    const string InputFileLocation = "http://mlxdevopsmlpoc.blob.core.windows.net/hddefault/data/output/AggExceptioneventVer7v0/2015/5/"; // Replace this with the location of your input file
    const string InputBlobName = "data/output/AggExceptioneventVer7v0/2015/5/000000_0"; // Replace this with the name you would like to use for your Azure blob; this needs to have the same extension as the input file 

    string storageConnectionString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};

    AccountKey={1}", StorageAccountName, StorageAccountKey);           

    var blobClient = CloudStorageAccount.Parse(storageConnectionString).CreateCloudBlobClient();           

    var container = blobClient.GetContainerReference(StorageContainerName);           

    container.CreateIfNotExists();           

    var blob = container.GetBlockBlobReference(InputBlobName);           

    blob.UploadFromFile(InputFileLocation, FileMode.Open);

    Am I using the wrong method of CloudBlockBlob object? I am stepping through the code and seeing that the values assigned to these variables look correct to me. Let me know if there is a different method to use or if there is some dependency I'm missing. Also let me know if you need more details to debug. Thank you in advance!
    Friday, May 29, 2015 10:53 PM

Answers

  • Two areas to check:

    1.  Check the format of your connection string.  If argumentexception was thrown, your connection string either can be null or empty.  You mentioned that your connection string looked correct so that may not be an issue here.

    2.  Try the following code instead.  I'd create a storage account first, and then a cloudBlobclient.  Let me know, if you need additional information.

               

    stringstorageConnectionString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", StorageAccountName, "accountkey");


    CloudStorageAccountstorageAccount = CloudStorageAccount.Parse(storageConnectionString);


    varblobClient = storageAccount.CreateCloudBlobClient();


    Sunday, May 31, 2015 12:19 AM

All replies

  • Hi Danielle F

    Thanks for posting here!

    Since I'm not very good with this topic, I shall involve someone from the team who is an expert in this matter.

    Sharing with you few links which you might find helpful.

    https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-blobs/

    https://msdn.microsoft.com/en-us/library/dd135715.aspx

    https://msdn.microsoft.com/en-us/library/dd179451.aspx

    https://msdn.microsoft.com/en-us/library/ee395424.aspx

    Regards,

    Sadiqh Ahmed

    ________________________________________________________________________________________________________________

    If a post answers your question, please click Mark As Answer on that post and Vote as Helpful.


    Saturday, May 30, 2015 6:21 PM
    Moderator
  • Two areas to check:

    1.  Check the format of your connection string.  If argumentexception was thrown, your connection string either can be null or empty.  You mentioned that your connection string looked correct so that may not be an issue here.

    2.  Try the following code instead.  I'd create a storage account first, and then a cloudBlobclient.  Let me know, if you need additional information.

               

    stringstorageConnectionString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", StorageAccountName, "accountkey");


    CloudStorageAccountstorageAccount = CloudStorageAccount.Parse(storageConnectionString);


    varblobClient = storageAccount.CreateCloudBlobClient();


    Sunday, May 31, 2015 12:19 AM
  • Hi Aung! Thanks for your advice.

    Unfortunately this did not work in my case - it still gives me the same 'URI format is not supported' error. Any other possible ideas? I am looking into these resources Sadiqh suggested as well in the meantime.

    -Danielle

    Monday, June 1, 2015 6:29 PM
  • Here are more details: I inserted a WriteLine of my main variables just above the line that is throwing the error, to make sure the variables look correct. Here is the output in the Console.

             storageConnectionString: DefaultEndpointsProtocol=https;AccountName=mlx
    devopsmlpoc;AccountKey=...,
             storageAccount: DefaultEndpointsProtocol=https;AccountName=mlxdevopsmlp
    oc;AccountKey=[key hidden],
             blobClient: Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient,
             container: Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer,
             blob: Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob,
             InputBlobName: data/output/AggExceptioneventVer7v0/2015/5/000000_0,
             StorageContainerName: hddefault,
             InputFileLocation: http://mlxdevopsmlpoc.blob.core.windows.net/hddefaul
    t/data/output/AggExceptioneventVer7v0/2015/5/000000_0

    NOTE: should I have the exact file name in the "InputFileLocation"? Or should I just have the path prefix, without the '000000_0' file name included? I tried both and neither solved the URI format error.

    Monday, June 1, 2015 6:43 PM