none
[Node.js] Azure storage issue

    Question

  •  

    I am getting error while storing a file to azure storage. I get below error. The specified resource does not exist

    Code:

    var azure = require('azure-storage');
    var blobSvc = azure.createBlobServiceAnonymous('https://lpevent.blob.core.windows.net/');

    blobSvc.createBlockBlobFromLocalFile('eventimages', 'myblob', 'config.json', function(error, result, response){
      if(!error){
        console.log("File uploaded successfully");
      }
      else
      {
        console.log("Error2: " + error);
      }
    });

    Environment variable set for

    AZURE_STORAGE_ACCOUNT=lpevent

    AZURE_STORAGE_ACCESS_KEY is set with proper key taken from azure

    Error:

    StorageError: The specified resource does not exist.
    RequestId:7eeb8438-0001-00e2-3bd8-b30096000000
    Time:2017-04-12T22:00:39.0903903Z




    Wednesday, April 12, 2017 10:01 PM

All replies

  • Basically, we can't create a blob file anonymously by using createBlobServiceAnonymous. You'll need to use createBlobService with your storage account name and access key instead.

    Please consider the following code to create a Blob:

    var azure = require('azure-storage')
    
    var accountName = "<your-account-name>"
    var accessKey = "<your-access-key>"
    
    var blobSvc = azure.createBlobService(accountName, accessKey)
    
    blobSvc.createBlockBlobFromLocalFile('eventimages', 'myblob', 'config.json', function(error, result, response){
      if(!error) {
        console.log("File uploaded successfully");
      } else
      {
        console.log("Error2: " + error);
      }
    });

     





    Friday, April 14, 2017 3:25 AM
    Moderator