Infanty Rajan
Infanty Rajan

Reputation: 21

Connection string for azure table storage for local connection

I am new to cloud development with the combination of azure table storage + node.js. In all samples I found the connection string for azure storage is only those who have account with real windows azure. As I am developing in my local PC need to the configuration of local azure storage account.

I tried with connection string as:

<add key="AZURE_STORAGE_ACCOUNT" value="DevStorage"/>
  <add key="AZURE_STORAGE_ACCESS_KEY" value="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="/>

It is possible connect azure storage via azure storage emulator not in code.

Can anyone get me the solution please??

Upvotes: 2

Views: 5146

Answers (3)

hejeroaz
hejeroaz

Reputation: 303

In my case, I has storage emulator running on outside virtual machine using Passport to redirect external requests at ports 20000, 20001, 20002, to localhost port 10000, 10001, 10002 inside this virtual machine...

var connectionString = 'DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://192.168.56.56:20000/devstoreaccount1;TableEndpoint=http://192.168.56.56:20002/devstoreaccount1;QueueEndpoint=http://192.168.56.56:20001/devstoreaccount1;';

var azure = require('azure-storage');
var tableSvc = azure.createTableService(connectionString);

var query = new azure.TableQuery()
  .top(5)
  .where('PartitionKey eq ?', 'CONDITION');

tableSvc.queryEntities('TABLENAME',query, null, function(error, result, response) {
    if(!error) {
      // query was successful
      console.log(result.entries);
    }
  });

Upvotes: 0

Jonathan McIntire
Jonathan McIntire

Reputation: 2675

Create your node.js table service client like this:

var azure = require('azure');
var tableClient = azure.createTableService(ServiceClient.DEVSTORE_STORAGE_ACCOUNT, ServiceClient.DEVSTORE_STORAGE_ACCESS_KEY, ServiceClient.DEVSTORE_TABLE_HOST);

By using DEVSTORE_STORAGE_ACCOUNT, DEVSTORE_STORAGE_ACCESS_KEY and DEVSTORE_BLOB_HOST, you're using the blob storage emulator settings which are hard coded in the node.js Azure SDK. This eliminates node.js configuration problems from the equation.

Upvotes: 1

Shaun Xu
Shaun Xu

Reputation: 4666

Try the connection information below to see if it's help.

Account Name = devstoreaccount1

Account key = Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==

Upvotes: 0

Related Questions