Azure 函数错误索引方法 - 远程调试器崩溃
Azure Function Error Indexing Method - Remote Debugger crashes
我有一个 azure 函数应用程序,所有功能都在本地运行。我可以成功将应用程序发布到 Azure,但所有端点 return 500 个服务器错误。
我的主机日志看起来像这样:
2018-09-17T15:05:14.801 [Information] Host Status: {
"id": "---function",
"state": "Default",
"version": "2.0.12095.0",
"versionDetails": "2.0.12095.0-rc1 Commit hash: beb6b6afde701a57----c051c082e2d1c738e18"
}
2018-09-17T15:05:16.555 [Information] Generating 11 job function(s)
2018-09-17T15:05:16.576 [Error] Error indexing method 'AddMaterial.Run'
2018-09-17T15:05:16.657 [Warning] Function 'AddMaterial.Run' failed indexing and will be disabled.
2018-09-17T15:05:16.658 [Error] Error indexing method 'ChangeMaterialWeight.Run'
2018-09-17T15:05:16.714 [Warning] Function 'ChangeMaterialWeight.Run' failed indexing and will be disabled.
2018-09-17T15:05:16.766 [Error] Error indexing method 'CheckIfOldestMaterial.Run'
2018-09-17T15:05:16.863 [Warning] Function 'CheckIfOldestMaterial.Run' failed indexing and will be disabled.
2018-09-17T15:05:16.864 [Error] Error indexing method 'CreateBoxType.Run'
2018-09-17T15:05:16.915 [Warning] Function 'CreateBoxType.Run' failed indexing and will be disabled.
2018-09-17T15:05:16.916 [Error] Error indexing method 'CreateFinishedGoods.Run'
2018-09-17T15:05:16.961 [Warning] Function 'CreateFinishedGoods.Run' failed indexing and will be disabled.
2018-09-17T15:05:16.962 [Error] Error indexing method 'CreateWarehouse.Run'
2018-09-17T15:05:17.005 [Warning] Function 'CreateWarehouse.Run' failed indexing and will be disabled.
2018-09-17T15:05:17.006 [Error] Error indexing method 'WarehousesAll.Run'
2018-09-17T15:05:17.053 [Warning] Function 'WarehousesAll.Run' failed indexing and will be disabled.
2018-09-17T15:05:17.054 [Error] Error indexing method 'MaterialByRollId.Run'
2018-09-17T15:05:17.115 [Warning] Function 'MaterialByRollId.Run' failed indexing and will be disabled.
2018-09-17T15:05:17.116 [Error] Error indexing method 'MaterialsByMaterialNumber.Run'
2018-09-17T15:05:17.177 [Warning] Function 'MaterialsByMaterialNumber.Run' failed indexing and will be disabled.
2018-09-17T15:05:17.178 [Error] Error indexing method 'MoveFinishedGoods.Run'
2018-09-17T15:05:17.220 [Warning] Function 'MoveFinishedGoods.Run' failed indexing and will be disabled.
2018-09-17T15:05:17.220 [Error] Error indexing method 'MoveMaterial.Run'
2018-09-17T15:05:17.256 [Warning] Function 'MoveMaterial.Run' failed indexing and will be disabled.
2018-09-17T15:05:17.258 [Warning] No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. config.UseServiceBus(), config.UseTimers(), etc.).
2018-09-17T15:05:17.258 [Information] Host initialized (2497ms)
2018-09-17T15:05:17.262 [Information] Host started (2501ms)
2018-09-17T15:05:17.266 [Information] Job host started
2018-09-17T15:05:22.298 [Information] Host lock lease acquired by instance ID '130a20de31f46----dc65791c3078124'.
我的存储连接字符串连同来自 local.settings.json
的其他设置一起填充到 Azure 门户应用程序设置中
我还尝试在 Azure 门户的连接字符串区域中填充我的所有连接字符串,因为我已阅读 local.settings.json should only be used locally。
我使用类似于 Environment.GetEnvironmentVariable("ReadDbConnectionDev");
的代码访问这些设置和连接字符串
编辑: 已确认连接字符串不是问题,因为我使用没有自定义绑定的新函数进行了测试,该函数能够正确记录它们在我的部署中。这里的问题似乎在于自定义绑定。
我有一个 azure sql 数据存储和一个正在连接的 cosmos db mongo 数据存储。我没有在我的函数中使用 cosmosdb 绑定。 相反,我使用带有自定义绑定的存储库模式来连接它。 同样,这在本地有效,我已经询问过它应该能够上班。
我正在使用 WebJobsStartUp 和扩展。
[assembly: WebJobsStartup(typeof(FunctionStartUp), name: "ESPI Function Startup Extension")]
namespace ESPIWarehouseFunction
{
public class FunctionStartUp : IWebJobsStartup
{
public void Configure(IWebJobsBuilder builder)
{
//Don't need to create a new service collection just use the built-in one
builder.Services.AddSingleton<IQueryService, QueryService>();
builder.Services.AddSingleton<IWarehouseStateRepository, WarehouseStateRepository>();
builder.Services.AddSingleton<IMaterialRepository, MaterialRepository>();
builder.Services.AddSingleton<IEventRepository, EventRepository>();
builder.Services.AddSingleton<IBoxRepository, BoxRepository>();
builder.Services.AddSingleton<IReadContext, ReadContext>();
builder.Services.AddSingleton<IStateContext, StateContext>();
builder.Services.AddSingleton<IStateContext, StateContext>();
builder.Services.AddSingleton<IEventStoreContext, EventStoreContext>();
builder.Services.AddMediatR(typeof(FunctionStartUp).GetTypeInfo().Assembly);
//Registering an extension
builder.AddExtension<InjectConfiguration>();
}
}
}
namespace ESPIWarehouseFunction.Injection
{
public class InjectConfiguration : IExtensionConfigProvider
{
private IServiceProvider _serviceProvider;
public InjectConfiguration(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
}
public void Initialize(ExtensionConfigContext context)
{
var services = new ServiceCollection();
RegisterServices(services);
_serviceProvider = services.BuildServiceProvider(true);
context
.AddBindingRule<InjectAttribute>()
.BindToInput<dynamic>(i => _serviceProvider.GetRequiredService(i.Type));
}
private void RegisterServices(IServiceCollection services)
{
services.AddSingleton<IWarehouseStateRepository, WarehouseStateRepository>();
services.AddSingleton<IQueryService, QueryService>();
services.AddSingleton<IMaterialRepository, MaterialRepository>();
services.AddSingleton<IEventRepository, EventRepository>();
services.AddSingleton<IBoxRepository, BoxRepository>();
services.AddSingleton<IReadContext, ReadContext>();
services.AddSingleton<IStateContext, StateContext>();
services.AddSingleton<IStateContext, StateContext>();
services.AddSingleton<IEventStoreContext, EventStoreContext>();
services.AddMediatR(typeof(InjectConfiguration));
}
}
}
我正在使用最新的 15.10.2009 版本 的 azure 函数网络作业工具和 1.0.21 Microsoft.NET.Sdk.Fuctions
将调试器附加到远程函数时,我的 visual studio 冻结并且我设置的断点显示 breakpoint cannot be reached
有人知道这里会发生什么吗?
所以这个问题与无法将 extensions.json 文件写入远程主机的错误有关。我用最新的sdk v1.0.19和1.0.21体验了一下。
这个github issue好像在跟踪它。
我可以通过使用云资源管理器将我的本地 extensions.json 文件复制到主机来解决这个问题。
我有一个 azure 函数应用程序,所有功能都在本地运行。我可以成功将应用程序发布到 Azure,但所有端点 return 500 个服务器错误。
我的主机日志看起来像这样:
2018-09-17T15:05:14.801 [Information] Host Status: {
"id": "---function",
"state": "Default",
"version": "2.0.12095.0",
"versionDetails": "2.0.12095.0-rc1 Commit hash: beb6b6afde701a57----c051c082e2d1c738e18"
}
2018-09-17T15:05:16.555 [Information] Generating 11 job function(s)
2018-09-17T15:05:16.576 [Error] Error indexing method 'AddMaterial.Run'
2018-09-17T15:05:16.657 [Warning] Function 'AddMaterial.Run' failed indexing and will be disabled.
2018-09-17T15:05:16.658 [Error] Error indexing method 'ChangeMaterialWeight.Run'
2018-09-17T15:05:16.714 [Warning] Function 'ChangeMaterialWeight.Run' failed indexing and will be disabled.
2018-09-17T15:05:16.766 [Error] Error indexing method 'CheckIfOldestMaterial.Run'
2018-09-17T15:05:16.863 [Warning] Function 'CheckIfOldestMaterial.Run' failed indexing and will be disabled.
2018-09-17T15:05:16.864 [Error] Error indexing method 'CreateBoxType.Run'
2018-09-17T15:05:16.915 [Warning] Function 'CreateBoxType.Run' failed indexing and will be disabled.
2018-09-17T15:05:16.916 [Error] Error indexing method 'CreateFinishedGoods.Run'
2018-09-17T15:05:16.961 [Warning] Function 'CreateFinishedGoods.Run' failed indexing and will be disabled.
2018-09-17T15:05:16.962 [Error] Error indexing method 'CreateWarehouse.Run'
2018-09-17T15:05:17.005 [Warning] Function 'CreateWarehouse.Run' failed indexing and will be disabled.
2018-09-17T15:05:17.006 [Error] Error indexing method 'WarehousesAll.Run'
2018-09-17T15:05:17.053 [Warning] Function 'WarehousesAll.Run' failed indexing and will be disabled.
2018-09-17T15:05:17.054 [Error] Error indexing method 'MaterialByRollId.Run'
2018-09-17T15:05:17.115 [Warning] Function 'MaterialByRollId.Run' failed indexing and will be disabled.
2018-09-17T15:05:17.116 [Error] Error indexing method 'MaterialsByMaterialNumber.Run'
2018-09-17T15:05:17.177 [Warning] Function 'MaterialsByMaterialNumber.Run' failed indexing and will be disabled.
2018-09-17T15:05:17.178 [Error] Error indexing method 'MoveFinishedGoods.Run'
2018-09-17T15:05:17.220 [Warning] Function 'MoveFinishedGoods.Run' failed indexing and will be disabled.
2018-09-17T15:05:17.220 [Error] Error indexing method 'MoveMaterial.Run'
2018-09-17T15:05:17.256 [Warning] Function 'MoveMaterial.Run' failed indexing and will be disabled.
2018-09-17T15:05:17.258 [Warning] No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. config.UseServiceBus(), config.UseTimers(), etc.).
2018-09-17T15:05:17.258 [Information] Host initialized (2497ms)
2018-09-17T15:05:17.262 [Information] Host started (2501ms)
2018-09-17T15:05:17.266 [Information] Job host started
2018-09-17T15:05:22.298 [Information] Host lock lease acquired by instance ID '130a20de31f46----dc65791c3078124'.
我的存储连接字符串连同来自 local.settings.json
我还尝试在 Azure 门户的连接字符串区域中填充我的所有连接字符串,因为我已阅读 local.settings.json should only be used locally。
我使用类似于 Environment.GetEnvironmentVariable("ReadDbConnectionDev");
编辑: 已确认连接字符串不是问题,因为我使用没有自定义绑定的新函数进行了测试,该函数能够正确记录它们在我的部署中。这里的问题似乎在于自定义绑定。
我有一个 azure sql 数据存储和一个正在连接的 cosmos db mongo 数据存储。我没有在我的函数中使用 cosmosdb 绑定。 相反,我使用带有自定义绑定的存储库模式来连接它。 同样,这在本地有效,我已经询问过它应该能够上班。
我正在使用 WebJobsStartUp 和扩展。
[assembly: WebJobsStartup(typeof(FunctionStartUp), name: "ESPI Function Startup Extension")]
namespace ESPIWarehouseFunction
{
public class FunctionStartUp : IWebJobsStartup
{
public void Configure(IWebJobsBuilder builder)
{
//Don't need to create a new service collection just use the built-in one
builder.Services.AddSingleton<IQueryService, QueryService>();
builder.Services.AddSingleton<IWarehouseStateRepository, WarehouseStateRepository>();
builder.Services.AddSingleton<IMaterialRepository, MaterialRepository>();
builder.Services.AddSingleton<IEventRepository, EventRepository>();
builder.Services.AddSingleton<IBoxRepository, BoxRepository>();
builder.Services.AddSingleton<IReadContext, ReadContext>();
builder.Services.AddSingleton<IStateContext, StateContext>();
builder.Services.AddSingleton<IStateContext, StateContext>();
builder.Services.AddSingleton<IEventStoreContext, EventStoreContext>();
builder.Services.AddMediatR(typeof(FunctionStartUp).GetTypeInfo().Assembly);
//Registering an extension
builder.AddExtension<InjectConfiguration>();
}
}
}
namespace ESPIWarehouseFunction.Injection
{
public class InjectConfiguration : IExtensionConfigProvider
{
private IServiceProvider _serviceProvider;
public InjectConfiguration(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
}
public void Initialize(ExtensionConfigContext context)
{
var services = new ServiceCollection();
RegisterServices(services);
_serviceProvider = services.BuildServiceProvider(true);
context
.AddBindingRule<InjectAttribute>()
.BindToInput<dynamic>(i => _serviceProvider.GetRequiredService(i.Type));
}
private void RegisterServices(IServiceCollection services)
{
services.AddSingleton<IWarehouseStateRepository, WarehouseStateRepository>();
services.AddSingleton<IQueryService, QueryService>();
services.AddSingleton<IMaterialRepository, MaterialRepository>();
services.AddSingleton<IEventRepository, EventRepository>();
services.AddSingleton<IBoxRepository, BoxRepository>();
services.AddSingleton<IReadContext, ReadContext>();
services.AddSingleton<IStateContext, StateContext>();
services.AddSingleton<IStateContext, StateContext>();
services.AddSingleton<IEventStoreContext, EventStoreContext>();
services.AddMediatR(typeof(InjectConfiguration));
}
}
}
我正在使用最新的 15.10.2009 版本 的 azure 函数网络作业工具和 1.0.21 Microsoft.NET.Sdk.Fuctions
将调试器附加到远程函数时,我的 visual studio 冻结并且我设置的断点显示 breakpoint cannot be reached
有人知道这里会发生什么吗?
所以这个问题与无法将 extensions.json 文件写入远程主机的错误有关。我用最新的sdk v1.0.19和1.0.21体验了一下。
这个github issue好像在跟踪它。
我可以通过使用云资源管理器将我的本地 extensions.json 文件复制到主机来解决这个问题。