How to use the azure-storage.createTableService function in azure-storage

To help you get started, we’ve selected a few azure-storage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure-Samples / iot-hub-c-m0wifi-getstartedkit / command_center_node / server.js View on Github external
var iotHubClient = ServiceClient.fromConnectionString(iotHubConnString);

// event hub alerts
var alerts = [];
var ehclient = EventHubClient.fromConnectionString(ehConnString, eventHubName)
ehclient.createReceiver('$Default', '0', { startAfterTime: Date.now() })
    .then(function(rx) {
        rx.on('errorReceived', function(err) { console.log(err); });
        rx.on('message', function(message) {
            alerts.push(message.body);
            alerts = alerts.slice(-5); // keep last 5
        });
    });

// table storage
var tableSvc = azure.createTableService(storageAcountName, storageAccountKey);
tableSvc.createTableIfNotExists(storageTable, function(err, result, response) {
    if (err) {
        console.log('error looking up table');
        console.log(err)
    }
});

// website setup
var app = express();
var port = nconf.get('port');
app.use(express.static('public'));
app.use(express.static('bower_components'));
app.use(bodyParser.json());

// app api
app.get('/api/alerts', function(req, res) {
github CatalystCode / project-fortis / project-fortis-services / src / clients / storage / AzureTableStorageManager.js View on Github external
InsertOrReplaceSiteDefinition(siteDefintion, callback){
    let tableService = azureStorage.createTableService();
    const tableEnity = Object.assign({}, siteDefintion, {
      defaultLocation: JSON.stringify(siteDefintion.defaultLocation),
      targetBbox: JSON.stringify(siteDefintion.targetBbox),
      supportedLanguages: JSON.stringify(siteDefintion.supportedLanguages),
      PartitionKey: AZURE_TBL_SITES_PARTITION_KEY,
      RowKey: siteDefintion.name
    });

    tableService.createTableIfNotExists(AZURE_TBL_SITES, (error, result, response) => { // eslint-disable-line no-unused-vars
      if(!error){
        tableService.insertOrReplaceEntity(AZURE_TBL_SITES, tableEnity, (error2, result, response) => { // eslint-disable-line no-unused-vars
          if(!error2){
            FetchSiteDefinitions(siteDefintion.name, tableService, callback);
          }else{
            callback(`There was an error writing to table [${AZURE_TBL_SITES}] with definition[${JSON.stringify(tableEnity)}]`);
          }
github dymajo / waka / server / vehicle.js View on Github external
'use strict'
var azure = require('azure-storage');
var tableSvc = azure.createTableService();

var vehicle = {
  vehicleDetails: function(agency, id) {
    let offset = 0
    // id's don't map one to one, so we have to transform
    if (agency === 'nzbgw' || agency === 'nzbwp' || agency === 'nzbml' || agency === 'nzbns') {
      agency = 'nzb'
      offset = 10000
    } else if (agency === 'rth') {
      offset = 21000
    } else if (agency === 'btl') {
      offset = 21000
    } else if (agency === 'ue') {
      offset = 23000
    } else if (agency === 'he') {
      offset = 24000
github microsoft / botbuilder-js / libraries / botbuilder-azure / src / tableStorage.ts View on Github external
private createTableService(storageAccountOrConnectionString: string, storageAccessKey: string, host: any): TableServiceAsync {
        const tableService = storageAccountOrConnectionString ? azure.createTableService(storageAccountOrConnectionString, storageAccessKey, host) : azure.createTableService();

        // create TableServiceAsync by using denodeify to create promise wrappers around cb functions
        return {
            createTableIfNotExistsAsync: this.denodeify(tableService, tableService.createTableIfNotExists),
            deleteTableIfExistsAsync: this.denodeify(tableService, tableService.deleteTableIfExists),
            retrieveEntityAsync: this.denodeify(tableService, tableService.retrieveEntity),
            insertOrReplaceEntityAsync: this.denodeify(tableService, tableService.insertOrReplaceEntity),
            replaceEntityAsync: this.denodeify(tableService, tableService.replaceEntity),
            deleteEntityAsync: this.denodeify(tableService, tableService.deleteEntity)
        } as any;
    }
github Azure / Azurite / test / 01_Basic_table_Tests.js View on Github external
it("should retrieve all Entities", (done) => {
      const query = new azureStorage.TableQuery();
      const retrievalTableService = azureStorage.createTableService(
        "UseDevelopmentStorage=true"
      );
      retrievalTableService.queryEntities(tableName, query, null, function(
        error,
        results,
        response
      ) {
        expect(error).to.equal(null);
        expect(results.entries.length).to.equal(2);
        const sortedResults = results.entries.sort();
        expect(sortedResults[0].description._).to.equal(
          tableEntity1.description._
        );
        expect(sortedResults[1].description._).to.equal(
          tableEntity2.description._
        );
github Azure / Azurite / test / 01_Basic_table_Tests.js View on Github external
function missingEntityFindTest(cb) {
      const query = new azureStorage.TableQuery()
        .top(5)
        .where("RowKey eq ?", "unknownRowKeyForFindError");
      const faillingFindTableService = azureStorage.createTableService(
        "UseDevelopmentStorage=true"
      );
      faillingFindTableService.queryEntities(tableName, query, null, function(
        error,
        result,
        response
      ) {
        expect(error.message).to.equal(EntityNotFoundErrorMessage);
        expect(response.statusCode).to.equal(404);
        cb();
      });
    }
  });
github DFEAGILEDEVOPS / MTC / _spikes-poc / tableStorageAnswers / insertData.js View on Github external
let azure = require('azure-storage')
let uuid = require('uuid/v4')
let readline = require('readline')
let util = require('util')
let async = require('async')

const answersTable = 'answersQueryPerfTest'
let tableSvc = azure.createTableService()

function insertData(done) {

  tableSvc.createTableIfNotExists(answersTable, function (error, result, response) {
    if (error) {
      done(error)
    } else {
      var batches = createBatches()
      async.eachOf(batches, function (batch, index, callback) {
        tableSvc.executeBatch(answersTable, batch, function (error, result, response) {
          if (error) {
            return callback(error)
          }
          else {
            console.log('batch %s inserted successfully', index)
            callback()
github CatalystCode / VoTT-web / server.js View on Github external
const bodyParser = require('body-parser');
const connect_ensure_login = require('connect-ensure-login');
const cookieParser = require('cookie-parser');
const express = require('express');
const expressSession = require('express-session');
const passport = require('passport');
const passportGithub = require('passport-github');
const path = require('path');
const NodeCache = require('node-cache');
const model = require('./src/model');

const blobServiceConnectionString = process.env.BLOB_SERVICE_CONNECTION_STRING;
const blobService = azureStorage.createBlobService(blobServiceConnectionString);

const tableServiceConnectionString = process.env.TABLE_SERVICE_CONNECTION_STRING;
const tableService = azureStorage.createTableService(tableServiceConnectionString);

const queueServiceConnectionString = process.env.QUEUE_SERVICE_CONNECTION_STRING;
const queueService = azureStorage.createQueueService(queueServiceConnectionString);

const accessRightsCache = new NodeCache({ stdTTL: 100, checkperiod: 120 });
const accessRightsService = new model.AccessRightsService(tableService, accessRightsCache);

passport.use(new passportGithub.Strategy(
  {
    clientID: process.env.GITHUB_CLIENT,
    clientSecret: process.env.GITHUB_SECRET,
    callbackURL: `${process.env.VOTT_HOSTNAME}/auth/github/callback`
  },
  (accessToken, refreshToken, profile, cb) => {
    return cb(null, profile);
  }
github microsoft / ghcrawler / src / factory / util / azure.js View on Github external
function createTableService(account, key) {
  factoryLogger.info(`creating table service`);
  const retryOperations = new AzureStorage.ExponentialRetryPolicyFilter();
  return AzureStorage.createTableService(account, key).withFilter(retryOperations);
}
github cloudlibz / nodecloud-azure-plugin / storage / table-storage.js View on Github external
constructor() {
    this._storageService = azureStorageService.createTableService();
  }