我有一个Azure功能应用程序,所有功能都在本地运行。我可以成功地发布该应用程序以使Azure失效,但是所有端点都返回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仅应在本地使用。
我使用类似于 Environment.GetEnvironmentVariable("ReadDbConnectionDev");
编辑: 已确认连接字符串不是问题,因为我使用没有自定义绑定的新功能进行了测试,该功能能够将它们正确记录在部署中。这里的问题似乎在于自定义绑定。
我要连接的Azure SQL数据存储区和Cosmos db mongo数据存储区。我没有在函数中使用cosmosdb绑定。 相反,我使用的是带有自定义绑定的存储库模式来连接到它。 同样,这在本地有效,并且我已经询问这应该可以工作。
我正在使用WebJobsStartUp和Extension。
[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));
}
}
}
我正在使用最新的 2009年10月15日版的Azure函数Web作业工具和 1.0.21 用于Microsoft.NET.Sdk.Fuctions
将调试器附加到远程功能时,Visual Studio冻结,并且设置的断点为breakpoint cannot be reached
有人知道这里可能发生什么吗?
答案 0 :(得分:1)
因此,此问题与未能将extensions.json文件写入远程主机的错误有关。我在最新的sdk v1.0.19和1.0.21中经历了这一点。
这个github issue似乎正在跟踪它。
我能够通过使用Cloud Explorer将本地extensions.json文件复制到主机上来解决此问题。