运行模拟器时,Azure表不存在错误
在运行Azure函数应用程序时,在连接表存储时会收到此错误。我在Azure中有一个表存储DB,还试图通过模拟器
Diconfig.cs注册服务&准备TableServiceClient
using Azure.Data.Tables;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Template.Infrastructure;
public static class DIConfig
{
public static IServiceCollection AddInfrastructure(this IServiceCollection services, IConfiguration configuration)
{
var tableClientConnectionString = configuration["AzureFunctionsJobHost:connectionStrings:tableStorage"];
services.AddScoped(_ => new TableServiceClient(tableClientConnectionString));
services.AddScoped(typeof(IRepository<>), typeof(TableClientRepository<>));
return services;
}
}
host.json
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"connectionStrings": {
"tableStorage": "UseDevelopmentStorage=true"
}
}
I am receiving this error when connecting my Table Storage when running my Azure function app. I have a Table Storage DB in Azure and also trying to run it through the emulator
DIConfig.cs to register services & prepare the TableServiceClient
using Azure.Data.Tables;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Template.Infrastructure;
public static class DIConfig
{
public static IServiceCollection AddInfrastructure(this IServiceCollection services, IConfiguration configuration)
{
var tableClientConnectionString = configuration["AzureFunctionsJobHost:connectionStrings:tableStorage"];
services.AddScoped(_ => new TableServiceClient(tableClientConnectionString));
services.AddScoped(typeof(IRepository<>), typeof(TableClientRepository<>));
return services;
}
}
Host.JSON
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"connectionStrings": {
"tableStorage": "UseDevelopmentStorage=true"
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您查看异常
不存在指定的表。
- 意味着模拟器工作正常,但是Azure表不存在。您只需添加代码( https://learn.microsoft.com/en-us/dotnet/api/opi/overview/azure/data.tables-readme-readme-prew.create-an-azure-table )该表存在。
If you look at the exception
The table specified does not exist.
- it means that emulator working just fine, but Azure table doesn't exist.You can just add in your code (https://learn.microsoft.com/en-us/dotnet/api/overview/azure/data.tables-readme-pre#create-an-azure-table) following code, which ensures that table exists.