none
Tables not working with Storage Emulator and NodeJS

    Question

  • I'm just getting started with NodeJS on Azure. So far it works very straight forward with nice getting started tutorials. However, I can't get Tables working following the tutorial at https://www.windowsazure.com/en-us/develop/nodejs/how-to-guides/table-services/

    This suggests that for running locally (using the Storage Emulator) you don't have to configure anything. Which is not the case. My application returned an Internal Server Error 500 "Error: connect ECONNREFUSED". The reason was that the Storage Emulator was not running, which in turn, had as reason that I was missing SQL Server on my system. So now I have installed SQL Server 2008 R2 Express edition. Now, the storage emulator runs fine.

    Still, I can't create or access Tables. from my NodeJS application. I get an error "Could not use table: InvalidInput". I guess it has to do with access to the SQL server, or non initialized SQL server. But I have no clue how to figure this out. Any ideas?

    My NodeJS app itself works fine when deployed to Azure, so this really has to do with the Storage Emulator. I also installed Azure Storage Explorer, in which I can create tables and entities locally without problem.

    Thursday, March 01, 2012 3:30 PM

Answers

  • Hi Jos,

    Sorry to hear you've run into trouble. Are you running your example directly in node.exe, or through the compute emulator? The how-to assumes you first used the PowerShell tools to create a hosted service and a WebRole and that you're running in the emulator.

    If you are doing it that way, then you'll notice that the Web.config creates an "EMULATED" environment variable, which enables the azure package to work without specifying storage access settings. It should all work seamlessly.

    If you want to try using the azure package directly with node.exe without going through the compute emulator, make sure you manually set the "EMULATED" environment variable. 

    Thanks,
    -Yavor


    If this answers your question, please mark as answered.
    Yavor Georgiev, Program Manager | Azure App Platform Team | Microsoft


    Tuesday, March 06, 2012 12:36 AM

All replies

  • Hi,

    Based on my understand, the error "Could not use table: InvalidInput" occurs when you trying to use a operation that not supported by table storage service, i guess you made some mistakes with your code, how do you write Node.js application, try to post your code to help us to fix your problems.

    Thank you.


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework

    Friday, March 02, 2012 9:21 AM
  • This is the code I have right now. It already fails when trying to create a table.

    var http = require('http');
    var azure = require('azure');
    
    var port = process.env.port || 1337;
    
    var tableName = 'tasklist';
    var tableService = azure.createTableService();
    
    http.createServer(function (req, res) {
      tableService.createTableIfNotExists(tableName, tableCreatedOrExists);
    
      function tableCreatedOrExists(error)  {
        res.writeHead(200, { 'Content-Type': 'text/plain' });
      
        if(error === null) {
          res.end('Using table ' + tableName + '\r\n');
        } else {
          res.end('Could not use table: ' + error.code + ', ' + error.message);
        }
      };
    }).listen(port);
    

    What may have to do with the issue too is that I got errors when installing azure via npm:

    PS C:\node\helloworld\HelloWorldWorker> npm install azure
    npm http GET https://registry.npmjs.org/azure
    npm http 503 https://registry.npmjs.org/azure
    npm ERR! registry error parsing json
    npm http GET https://registry.npmjs.org/sax
    npm http GET https://registry.npmjs.org/qs
    npm http GET https://registry.npmjs.org/log
    npm http GET https://registry.npmjs.org/xmlbuilder
    npm http GET https://registry.npmjs.org/mime
    npm http GET https://registry.npmjs.org/dateformat/1.0.2-1.2.3
    npm http GET https://registry.npmjs.org/xml2js
    npm http 503 https://registry.npmjs.org/qs
    npm ERR! registry error parsing json
    npm http 503 https://registry.npmjs.org/sax
    npm ERR! registry error parsing json
    npm http 503 https://registry.npmjs.org/xmlbuilder
    npm ERR! registry error parsing json
    npm http 503 https://registry.npmjs.org/log
    npm ERR! registry error parsing json
    npm http 503 https://registry.npmjs.org/mime
    npm ERR! registry error parsing json
    npm http 503 https://registry.npmjs.org/xml2js
    npm ERR! registry error parsing json
    azure@0.5.2 ./node_modules/azure
    ├── dateformat@1.0.2-1.2.3
    ├── xmlbuilder@0.3.1
    ├── log@1.3.0
    ├── mime@1.2.5
    ├── xml2js@0.1.13
    ├── qs@0.4.2
    └── sax@0.3.5
    

    Friday, March 02, 2012 10:42 AM
  • I just tried again to install azure with npm, now it works fine.

    PS C:\node\helloworld\HelloWorldWorker> npm -v
    1.1.0-3
    PS C:\node\helloworld\HelloWorldWorker> npm install azure
    npm http GET https://registry.npmjs.org/azure
    npm http 304 https://registry.npmjs.org/azure
    npm http GET https://registry.npmjs.org/sax
    npm http GET https://registry.npmjs.org/log
    npm http GET https://registry.npmjs.org/xmlbuilder
    npm http GET https://registry.npmjs.org/qs
    npm http GET https://registry.npmjs.org/dateformat/1.0.2-1.2.3
    npm http GET https://registry.npmjs.org/xml2js
    npm http GET https://registry.npmjs.org/mime
    npm http 304 https://registry.npmjs.org/sax
    npm http 304 https://registry.npmjs.org/log
    npm http 304 https://registry.npmjs.org/xmlbuilder
    npm http 304 https://registry.npmjs.org/qs
    npm http 304 https://registry.npmjs.org/xml2js
    npm http 304 https://registry.npmjs.org/dateformat/1.0.2-1.2.3
    npm http 304 https://registry.npmjs.org/mime
    azure@0.5.2 ./node_modules/azure
    ├── xmlbuilder@0.3.1
    ├── dateformat@1.0.2-1.2.3
    ├── mime@1.2.5
    ├── xml2js@0.1.13
    ├── log@1.3.0
    ├── qs@0.4.2
    └── sax@0.3.5
    However, I still get the exact same response, "Could not use table: InvalidInput, One of the request inputs is not valid."

    Friday, March 02, 2012 10:48 AM
  • Hi,

    You code looks good, and but i am wondering how do you configure your storage settings, and where does this error was thrown, create TableService or create Table failed?


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework

    Friday, March 02, 2012 3:14 PM
  • I have not done any storage configuration. I have left the Web.config as it is. From the tutorial:

    "If you are running against the storage emulator on the local machine, you do not need to configure a connection string, as it will be configured automatically. You can continue to the next section."

    When I click the system tray icon of the Emulator, and I click on the Storage Emulator UI, everything seems to run fine, but there are no configuration options. Do I maybe miss some configuration?

    Friday, March 02, 2012 3:21 PM
  • Hi Jos,

    Sorry to hear you've run into trouble. Are you running your example directly in node.exe, or through the compute emulator? The how-to assumes you first used the PowerShell tools to create a hosted service and a WebRole and that you're running in the emulator.

    If you are doing it that way, then you'll notice that the Web.config creates an "EMULATED" environment variable, which enables the azure package to work without specifying storage access settings. It should all work seamlessly.

    If you want to try using the azure package directly with node.exe without going through the compute emulator, make sure you manually set the "EMULATED" environment variable. 

    Thanks,
    -Yavor


    If this answers your question, please mark as answered.
    Yavor Georgiev, Program Manager | Azure App Platform Team | Microsoft


    Tuesday, March 06, 2012 12:36 AM