'AdlsClient' 不包含 'CreateDocumentAsync' 的定义
'AdlsClient' does not contain a definition for 'CreateDocumentAsync'
目标:
创建控制台应用程序,它 1) 从 Azure Data Lake Store 读取 json 2) 将数据存储到 Cosmos DB 为 json.
问题:
我可以读取文件 (1),但无法将数据存储到 Cosmos。查看错误。
错误:
严重性代码描述项目文件行抑制状态
错误 CS1061 'AdlsClient' 不包含 'CreateDocumentAsync' 的定义,并且找不到接受类型 'AdlsClient' 的第一个参数的扩展方法 'CreateDocumentAsync'(您是否缺少 using 指令或程序集参考?)CircleCustomActivityCosmosDB C:\AzureCoding\CustomActivityCosmosDB\Program.cs
代码:
private async Task CreateDocumentsAsync()
{
string fileName = "/myjsonfile.json";
// Obtain AAD token for ADLS
var creds = new ClientCredential(applicationId, clientSecret);
var clientCreds = ApplicationTokenProvider.LoginSilentAsync(tenantId, creds).GetAwaiter().GetResult();
// Create ADLS client object
AdlsClient client = AdlsClient.CreateClient(adlsAccountFQDN, clientCreds);
String json = "";
//Read file contents
using (var readStream = new StreamReader(client.GetReadStream(fileName)))
{
string line;
while ((line = readStream.ReadLine()) != null)
{
Console.WriteLine("Read file Line: " + line);
json += line;
}
}
//Read file to json
JsonTextReader reader = new JsonTextReader(new StringReader(json));
//Storing json to CosmosDB
Uri collectionUri = UriFactory.CreateDocumentCollectionUri(databaseName, collectionName);
//ERROR HAPPENS HERE - 'AdlsClient' does not contain a definition for 'CreateDocumentAsync' and no extension method 'CreateDocumentAsync'
await client.CreateDocumentAsync(collectionUri, reader);
}
}
没有为 class AdlsClient
定义的 CreateDocumentAsync
方法,请参阅 the docs
你需要一个 CosmosDB 客户端来在那里创建文档,我想你想改用 DocumentClient.CreateDocument。
AdlsClient
class 提供了仅访问 Azure Data Lake Store 而非 CosmosDB 数据存储的方法。为此,您需要 DocumentClient
class,请参阅 the docs。
如此总结:
TARGET: Create Console Application, which 1) Read json from Azure Data Lake Store 2) Store data to Cosmos DB as json.
对于 1) 您需要 AdlsClient(访问 adls)
对于 2) 您需要 DocumentClient(以访问 cosmosdb)
目标: 创建控制台应用程序,它 1) 从 Azure Data Lake Store 读取 json 2) 将数据存储到 Cosmos DB 为 json.
问题: 我可以读取文件 (1),但无法将数据存储到 Cosmos。查看错误。
错误: 严重性代码描述项目文件行抑制状态 错误 CS1061 'AdlsClient' 不包含 'CreateDocumentAsync' 的定义,并且找不到接受类型 'AdlsClient' 的第一个参数的扩展方法 'CreateDocumentAsync'(您是否缺少 using 指令或程序集参考?)CircleCustomActivityCosmosDB C:\AzureCoding\CustomActivityCosmosDB\Program.cs
代码:
private async Task CreateDocumentsAsync()
{
string fileName = "/myjsonfile.json";
// Obtain AAD token for ADLS
var creds = new ClientCredential(applicationId, clientSecret);
var clientCreds = ApplicationTokenProvider.LoginSilentAsync(tenantId, creds).GetAwaiter().GetResult();
// Create ADLS client object
AdlsClient client = AdlsClient.CreateClient(adlsAccountFQDN, clientCreds);
String json = "";
//Read file contents
using (var readStream = new StreamReader(client.GetReadStream(fileName)))
{
string line;
while ((line = readStream.ReadLine()) != null)
{
Console.WriteLine("Read file Line: " + line);
json += line;
}
}
//Read file to json
JsonTextReader reader = new JsonTextReader(new StringReader(json));
//Storing json to CosmosDB
Uri collectionUri = UriFactory.CreateDocumentCollectionUri(databaseName, collectionName);
//ERROR HAPPENS HERE - 'AdlsClient' does not contain a definition for 'CreateDocumentAsync' and no extension method 'CreateDocumentAsync'
await client.CreateDocumentAsync(collectionUri, reader);
}
}
没有为 class AdlsClient
定义的 CreateDocumentAsync
方法,请参阅 the docs
你需要一个 CosmosDB 客户端来在那里创建文档,我想你想改用 DocumentClient.CreateDocument。
AdlsClient
class 提供了仅访问 Azure Data Lake Store 而非 CosmosDB 数据存储的方法。为此,您需要 DocumentClient
class,请参阅 the docs。
如此总结:
TARGET: Create Console Application, which 1) Read json from Azure Data Lake Store 2) Store data to Cosmos DB as json.
对于 1) 您需要 AdlsClient(访问 adls)
对于 2) 您需要 DocumentClient(以访问 cosmosdb)