因此,我正在编写一个小的Azure函数来计算StorageAccount表中唯一实体的总数。到目前为止,除连接到存储表外,其他所有东西都可以正常工作。在开发过程中,我使用了Function的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
装饰器-显然-无法正常工作。
private static readonly string BLOB_STORAGE_CONNECTION_STRING = Environment.GetEnvironmentVariable("AzureWebJobsStorage");
TableAttribute
表示您要告诉绑定,连接字符串设置的名称为fwetabletest。确保具有名为
fwetabletest的连接字符串设置,该功能指向Function App Configuration下的'external'存储帐户,您应该可以使用。
[Table("BlaBlub", Connection = "fwetabletest")]