问题描述
我有一个Azure函数,该函数会在服务总线主题上触发并将其从Blob存储复制数据到Azure Cosmos Db Table Api。根据Azure Blob存储中的文件名,文件数据将作为实体复制到Cosmos Db表Api中的相应表中。
问题:对于要动态复制的每个文件,我想在代码中引用表名,如果表不存在,那么我将在cosmos db中创建一个。
例如,我在Azure函数中有以下代码:
public static async void Run([ServiceBusTrigger("SBTopic","SBSubscription",Connection = "AzureServiceBusString")] string mySbMsg,[CosmosDB(
databaseName: "DBName",collectionName: "{Dynamic table name}",ConnectionStringSetting = "CosmosDBConnection")] DocumentClient client,ILogger log)
{
try {
log.LogInformation($"C# ServiceBus topic trigger function processed message: {mySbMsg}");
// I get the variable name which will be my table name. Now refrencing this table name in Cosmos Db
CloudTable table = client.GetTableReference(client);
if (await table.CreateIfNotExistsAsync(Dynamic table name))
{ log("Created Table named: {0}",Dynamic table name);
// start copying entity
}
else
{ log("Table {0} already exists",Dynamic table name);
// start copying entity
}.
在此动态表名称中,该名称将来自以相同方法运行的另一组代码。所以现在的问题是,我该如何首先处理Cosmos Db Connection,以及如何在代码中引用它。
谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)