當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript azure-storage.createTableService函數代碼示例

本文整理匯總了TypeScript中azure-storage.createTableService函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript createTableService函數的具體用法?TypeScript createTableService怎麽用?TypeScript createTableService使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了createTableService函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: async

module.exports = async (context, req) => {

    const tableService = storage.createTableService();
    const entGen = storage.TableUtilities.entityGenerator;
    const tableName = `AzureWebJobsHostLogs${moment(moment().toISOString()).format('YYYYMM')}`;
    
    const checkTableExists: any = async () => {
        return new Promise((resolve, rejects) => {
            tableService.createTableIfNotExists(tableName, function(error, result, response) {
                resolve(result);
            });
        });
    }

    const checkTbl = await checkTableExists();
    if (checkTbl.isSuccessful === false) return false;

    //bolbにテーブルログの情報を取得
    const getFileSuccess: any = async (query) => {
        return new Promise((resolve, reject) => {
            tableService.queryEntities(tableName, query, null, (err, data) => {
                if (err) reject(undefined);
                else resolve(data.entries.length > 0 ? data.entries : undefined);    
            });
        });
    };

    const query = new storage.TableQuery()
        .where('fileHandleComplete != ?', '')
        .and('EndTime >= ?', new Date(moment(moment().subtract(1, 'days')).toISOString()));

    const events = await getFileSuccess(query);
    if (events === undefined) return false;

    if (events !== undefined) {
        for(let x in events) {
            let event = events[x];
            if (event.moveDate !== undefined) continue;

            const oriBlob    = 'working/' + event.fileHandleComplete._;
            const targetBlob = 'complete/' + event.fileHandleComplete._;
            const oriUrl     = event.fileHandleUrl._;

            let copyHandle = await new Promise((resolve ,reject) => {
                storage.createBlobService().startCopyBlob(oriUrl, process.env.AZURE_BLOB_STORAGE, targetBlob, async (err, result, res) => {
                    if (err) return reject(false);
                    return resolve(true);
                });
            });

            if (copyHandle === false) continue;
            let deleteHandle = await new Promise((resolve ,reject) => {
                storage.createBlobService().deleteBlobIfExists(process.env.AZURE_BLOB_STORAGE, oriBlob, async (err, result, res) => {
                    if (err) return reject(false);
                    return resolve(true);
                })
            });
        }
    }
}
開發者ID:motionpicture,項目名稱:ttts-functions,代碼行數:60,代碼來源:index.ts

示例2: it

  it('SetDefaultPortProperly', function (done) {
    var storageAccount = 'account';
    var storageAccountKey = new Buffer('key').toString('base64');

    var service = azure.createTableService(storageAccount, storageAccountKey, 'https://account.table.core.windows.net');
    assert.equal(service.host.primaryHost, 'https://account.table.core.windows.net:443/');

    var service = azure.createTableService(storageAccount, storageAccountKey, 'https://account.table.core.windows.net:21');
    assert.equal(service.host.primaryHost, 'https://account.table.core.windows.net:21/');

    service = azure.createTableService(storageAccount, storageAccountKey, 'http://account.table.core.windows.net');
    assert.equal(service.host.primaryHost, 'http://account.table.core.windows.net:80/');

    service = azure.createTableService(storageAccount, storageAccountKey, 'http://account.table.core.windows.net:81');
    assert.equal(service.host.primaryHost, 'http://account.table.core.windows.net:81/');

    done();
  });
開發者ID:litek,項目名稱:azure-storage-node,代碼行數:18,代碼來源:tableservice-tests.ts

示例3: function

var setupAzureTable = function()
{
    var tableService;
    var path = '_private/azure.txt';
    
    try {
        var file = fs.readFileSync(path);
        var creds = file.toString().split(',');
        var account = creds[0];
        var key = creds[1];
        
        tableService = azure.createTableService(account, key);
        
    } catch (e) {
        
        // if we couldn't find the file there
        tableService = azure.createTableService();
    }
    
    return tableService;
}
開發者ID:GoodSky,項目名稱:goodsky-azure,代碼行數:21,代碼來源:server.ts

示例4: async

    processComplete: async (context) => {
        const tableName     = 'AzureWebJobsHostLogs' + moment(moment().toISOString()).format('YYYYMM');
        const tableService  = storage.createTableService();

        const checkTableExists: any = async () => {
            return new Promise((resolve, rejects) => {
                tableService.createTableIfNotExists(tableName, (error, result, response) => resolve(result));
            });
        };

        //ログテーブルがなければ止まります
        const checkTbl = await checkTableExists();
        if (checkTbl.isSuccessful !== true) return false;

        //該當処理の情報を取得
        const getCurrentHandle: any = async (query) => {
            return new Promise((resolve, reject) => {
                tableService.queryEntities(tableName, query, null, (err, data) => {
                    if (err) reject(err);
                    else resolve(data.entries.length > 0 ? data.entries[0] : undefined);    
                });
            });
        };
        const query = new storage.TableQuery().where('RowKey == ?', context.funcId);
        const processHandle = await getCurrentHandle(query);
        if (processHandle === undefined) return false;

        //TRUEをprocessCompleteカラムに設定
        const setProcessComplete: any = async (processHandle: any) => {
            return new Promise((resolve, reject) => {
                tableService.insertOrReplaceEntity(tableName, processHandle, function(err) {
                    if (err) reject(err);
                    else resolve(true);
                });
            });
        }

        const entGen = storage.TableUtilities.entityGenerator;
        processHandle.fileHandleComplete = entGen.String(context.bindingData.name);
        processHandle.fileHandleUrl = entGen.String(context.bindingData.uri + '?sasString');
        await setProcessComplete(processHandle);
    },
開發者ID:motionpicture,項目名稱:ttts-functions,代碼行數:42,代碼來源:pos_sales.ts

示例5: async

const writeTableLog = async (context: any, error: any) => {
    var entGen = storage.TableUtilities.entityGenerator;
    const tableService = storage.createTableService();
    const tableName = `AzureWebJobsHostLogs${moment(moment().toISOString()).format('YYYYMM')}`;

    var entity = {
        PartitionKey: entGen.String('I'),
        RowKey: entGen.String(`${context.executionContext.invocationId}`),
        ErrorDetails: entGen.String(error),
        EndTime: entGen.DateTime(new Date(moment().toISOString()))
    };
    
    //エラーのレコードをインサートする
    const saveError: any = async (entity: any) => {
        return new Promise((resolve, reject) => {
            tableService.insertOrReplaceEntity(tableName, entity, function(error) {
                if (error) reject(error);
                else resolve(true);
            });
        });
    }

    await saveError(entity);
}
開發者ID:motionpicture,項目名稱:ttts-functions,代碼行數:24,代碼來源:logHelper.ts

示例6:

import * as fs from "fs";
import * as assert from "assert";
import * as util from "util";
import * as http from "http";
import * as azure from "azure-storage";

import TableQuery = azure.TableQuery;
import TableUtilities = azure.TableUtilities;
import eg = TableUtilities.entityGenerator;

var tableName = 'tablequerysample';
var tableService = azure.createTableService();

// optionally set a proxy
/*var proxy = {
  protocol: 'http:',
  host: '127.0.0.1',
  port: 8888
};

tableService.setProxy(proxy);*/

export interface EntityType extends azure.TableService.TableEntity {
  integerfield?: eg.EntityProperty<number>; 
  stringfield?: eg.EntityProperty<number>; 
  longfield?: eg.EntityProperty<number>; 
}

var entity1 = {
  PartitionKey: eg.String('partition1'),
  RowKey: eg.String('row1'),
開發者ID:litek,項目名稱:azure-storage-node,代碼行數:31,代碼來源:tablequerysample.ts

示例7: done

 suite.setupSuite(function () {
   tableService = azure.createTableService().withFilter(new azure.ExponentialRetryPolicyFilter());
   done();
 });   
開發者ID:litek,項目名稱:azure-storage-node,代碼行數:4,代碼來源:tabledatatype-tests.ts


注:本文中的azure-storage.createTableService函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。