我有下面的 Azure 函数,我能够成功发布并调试,我在本地运行它,我得到以下错误。有人可以告诉我这个错误是怎么回事,我该如何解决?
我的功能代码:
namespace MigrateDbWithChangeFeed
{
public static class CopyFunction
{
[FunctionName( "MigrateWithChangeFeed" )]
public static async Task Run( [CosmosDBTrigger(
databaseName: "sourcedb",
collectionName: "sourcecollection",
StartFromBeginning = true,
ConnectionStringSetting = "CosmosDBConnection",
LeaseCollectionName = "leases",
CreateLeaseCollectionIfNotExists = true
)] IReadOnlyList<Document> source, DocumentClient client,
ILogger log )
{
string continuationToken = null;
do
{
var feed = client.CreateDocumentQuery(
UriFactory.CreateDocumentCollectionUri( "sourcedb", "sourcecollection" ),
new SqlQuerySpec( "select * FROM c WHERE IS_DEFINED(c.ClassId)" ),
new FeedOptions
{
MaxItemCount = 100,
EnableCrossPartitionQuery = true,
RequestContinuation = continuationToken
} ).AsDocumentQuery();
var result = await feed.ExecuteNextAsync();
continuationToken = result.ResponseContinuation;
foreach( var doc in result )
{
string customerName = string.Empty;
var jsonContent = (JObject)JsonConvert.DeserializeObject( doc.ToString() );
customerName = (string)jsonContent["Customer"];
if( string.IsNullOrEmpty( customerName ) )
{
customerName = projectCustomerNameMapping
.FirstOrDefault( q => q.Key.IndexOf( (string)jsonContent["Project"] ) != -1 ||
((string)jsonContent["Project"]).IndexOf( q.Key ) != -1 ).Value ?? "Unknown";
}
string partitionkeyValue = string.Concat( (string)jsonContent["ClassId"],
"|",
(string)jsonContent["Project"],
"|",
customerName );
jsonContent.Add( new JProperty( "PartitionKey", partitionkeyValue ) );
await client.CreateDocumentAsync( UriFactory.CreateDocumentCollectionUri(
"dbname", "testtransform2" ),
jsonContent );
}
}
while( continuationToken != null );
}
public static Dictionary<string, string> projectCustomerNameMapping =
JsonConvert.DeserializeObject<Dictionary<string, string>>( File.ReadAllText( "CustomerSection.json" ) );
}
}
错误索引方法“MigrateWithChangeFeed”[2021-08-25T08:58:18.983Z] Microsoft.Azure.WebJobs.Host:错误索引方法“MigrateWithChangeFeed”。Microsoft.Azure.WebJobs.Host:无法将参数“client”绑定到类型 DocumentClient。确保绑定支持参数类型。如果您正在使用绑定扩展(例如 Azure 存储、ServiceBus、计时器等),请确保您已在启动代码中调用了扩展的注册方法(例如 builder.AddAzureStorage()、builder.AddServiceBus( )、builder.AddTimers() 等)。[2021-08-25T08:58:18.984Z] 函数“MigrateWithChangeFeed”索引失败,将被禁用。[2021-08-25T08:58:18.986Z] 未找到工作职能。尝试公开您的工作类别和方法。如果您使用绑定扩展(例如 Azure Storage、ServiceBus、