Azure functions 如何在Azure函数参数中调用动态值
我有一个Azure函数,它在服务总线主题上触发,它将数据从blob存储复制到Azure Cosmos Db表Api。根据Azure Blob存储中的文件名,文件数据将作为实体复制到Cosmos Db table Api中的相应表中 问题:我想在代码中引用动态复制的每个文件的表名,如果表不存在,我将在cosmos db中创建一个 例如,我在Azure函数中有以下代码:Azure functions 如何在Azure函数参数中调用动态值,azure-functions,azure-cosmosdb-tables,Azure Functions,Azure Cosmosdb Tables,我有一个Azure函数,它在服务总线主题上触发,它将数据从blob存储复制到Azure Cosmos Db表Api。根据Azure Blob存储中的文件名,文件数据将作为实体复制到Cosmos Db table Api中的相应表中 问题:我想在代码中引用动态复制的每个文件的表名,如果表不存在,我将在cosmos db中创建一个 例如,我在Azure函数中有以下代码: public static async void Run([ServiceBusTrigger("SBTopic&quo
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连接,以及如何在代码中引用它
谢谢您可以检查这一点:并尝试类似的cosmos db绑定
BlobAttribute dynamicBlobBinding = new BlobAttribute(blobPath: $"{path details}/{dynamic property 1}/{dynamic property2}");
您还可以参考并检查这在该场景中是否有用