• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript azure-storage.createTableService函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript azurerestutility.js.default类代码示例发布时间:2022-05-25
下一篇:
TypeScript azure-storage.createQueueService函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap