Question

I am trying to write some server scripts in Azure Mobile Service using the getBlob method of BlobService class. However, I got the following error:

TypeError: Object [object Object] has no method 'getBlob'

The method is described in the BlobService document: http://dl.windowsazure.com/nodedocs/BlobService.html, but why isn't available? Any idea?

Here is the code segment that I have tried so far:

var azure = require('azure');

function insert(item, user, request) {

var blobService = azure.createBlobService("accountName", "accountKey");

blobService.getBlob("myContainerName", "myBlobName", function(error, blob) {

    if (error != null) {
        console.error("Error!");
    } else { 
        console.log("blob: ", blob);
    }

});

Thanks!

** I found that the code seems to work fine using Node version 0.10.26 installed by Npm but doesn't work when I deploy it to the Azure Mobile Service that uses Node version 0.8.26. How can I change the Node version in Azure Mobile Service? I tried to change the Node version number in package.json and then commit through "git push origin master" but nothing changes.

Was it helpful?

Solution

The issue is around the version of the azure module that is included with Mobile Services, in order to not break some things, an older version of the Azure module is installed while the current is 0.9.6. In order to get the latest version of the Azure module, please follow these steps:

  1. Turn on Script Source Control (this can be done from the Dashboard of your Mobile Service in the Azure portal).
  2. Clone the git repository created by turning on Script Source Control.
  3. Navigate into the Service folder of the directory of your local git repo.
  4. Run this command: npm install azure --save
  5. This will install the latest module locally as well as adjust your packages.json to make sure that version is pulled down when you push your changes.
  6. Push the changes (git add, git commit, git push) back to Azure.

You should then be able to execute the getBlob method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top