Durable Task SQL Provider部署Azure后监听器启动失败求助
Durable Task SQL Provider部署到Azure后监听器启动失败:登录异常但可插入数据
环境信息
- 函数类型:C# .NET 8 Isolated模式
- 数据库:Azure SQL数据库
- 已手动执行脚本创建Durable Task相关对象
- 登录账号拥有
db_owner和dt_runtime角色 - 可调用
dt.CreateInstance并向dt.NewEvents、dt.Instances、dt.Payloads表插入数据
异常日志
2024-09-13T12:50:46.523 [Error] The listener for function 'Functions.Activity_CheckConnections' was unable to start. Microsoft.Azure.WebJobs.Host.Listeners.FunctionListenerException : The listener for function 'Functions.Activity_CheckConnections' was unable to start. ---> Microsoft.Data.SqlClient.SqlException : Login failed for user '<token-identified principal>'. at Microsoft.Data.ProviderBase.DbConnectionPool.CheckPoolBlockingPeriod(Exception e) at Microsoft.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject,DbConnectionOptions userOptions,DbConnectionInternal oldConnection) at Microsoft.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject,DbConnectionOptions userOptions,DbConnectionInternal oldConnection) at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject,UInt32 waitForMultipleObjectsTimeout,Boolean allowCreate,Boolean onlyOneCheckConnection,DbConnectionOptions userOptions,DbConnectionInternal& connection) at Microsoft.Data.ProviderBase.DbConnectionPool.WaitForPendingOpen() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at async DurableTask.SqlServer.SqlDbManager.EnsureDatabaseExistsAsync() at /_/src/DurableTask.SqlServer/SqlDbManager.cs : 183 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at async DurableTask.SqlServer.SqlDbManager.AcquireDatabaseLockAsync(Boolean createDatabaseIfNotExists) at /_/src/DurableTask.SqlServer/SqlDbManager.cs : 137 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at async DurableTask.SqlServer.SqlDbManager.CreateOrUpgradeSchemaAsync(Boolean recreateIfExists) at /_/src/DurableTask.SqlServer/SqlDbManager.cs : 33 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at async Microsoft.Azure.WebJobs.Extensions.DurableTask.DurableTaskExtension.StartTaskHubWorkerIfNotStartedAsync() at D:\a\_work\1\s\src\WebJobs.Extensions.DurableTask\DurableTaskExtension.cs : 1414 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at async Microsoft.Azure.WebJobs.Host.Listeners.FunctionListener.StartAsync(??) at D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Listeners\FunctionListener.cs : 68 End of inner exception
hosts.json配置
{ "version": "2.0", "functionTimeout": "-1", "logging": { "logLevel": { "Default": "Information", "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information", "Microsoft.EntityFrameworkCore.Database.Command": "Warning", "DurableTask.SqlServer": "Debug", "DurableTask.Core": "Debug" }, "applicationInsights": { "samplingSettings": { "isEnabled": true, "excludedTypes": "Request" }, "enableLiveMetricsFilters": true } }, "extensions": { "durableTask": { "hubName": "ICHub", "storageProvider": { "type": "mssql", "connectionStringName": "IgniteDBConnString", "taskEventLockTimeout": "00:02:00", "createDatabaseIfNotExists": true, "schemaName": "dt" } } } }
核心问题
本地运行正常,但部署到Azure后编排任务启动后一直处于挂起状态。所有Activity函数的监听器启动时均抛出SQL登录失败异常,然而当前登录账号却能正常向Durable Task相关表插入数据。
跟踪SQL Provider源码发现,监听器启动流程中会尝试连接master数据库检查目标数据库是否存在,但应用账号通常不会被授予master数据库的访问权限,这应该是导致登录失败的直接原因。
内容的提问来源于stack exchange,提问作者CodeRedick
相关产品推荐
相关产品推荐

