【发布时间】:2020-02-26 20:49:45
【问题描述】:
所以我正在编写一个小的 Azure 函数来计算 StorageAccount 表中唯一实体的总数。到目前为止,一切正常,除了与存储表的连接。在开发过程中,我使用了函数的 StorageAccount,它运行良好。但现在我需要连接到不同的 StorageAccount 表。
这是我目前得到的:
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Onkeliroh.Test
{
public static class TableStorageEntityCounter
{
[StorageAccount("fwetabletest")]
[FunctionName("TableStorageEntityCounter")]
public static async Task Run([TimerTrigger("0 */1 * * * *")] TimerInfo myTimer,
[Table("BlaBlub", Connection = "fwetabletest")]CloudTable cloudTable,
ILogger log)
{
var totalCount = await GetCountOfEntitiesInPartition(cloudTable);
log.LogInformation("Total Entity Count:" + totalCount.ToString());
}
public static async Task<int> GetCountOfEntitiesInPartition(CloudTable table)
{ \\[...]
}
}
}
我位于同一个 ResourceGroup 中的“外部”StorageAccount。
我的问题是:如何告诉我的函数使用另一个 StorageAccount? StorageAccount 装饰器——显然——不起作用。
【问题讨论】:
-
您应该有一个 AppSetting "fwetabletest",其中包含到您的外部存储的连接字符串。这一切都应该工作
标签: c# azure azure-functions azure-storage azure-table-storage