gpt4 book ai didi

Azure Web 作业 - 如何连接到 Azure MS SQL 数据库?

转载 作者:行者123 更新时间:2023-12-01 02:19:22 25 4
gpt4 key购买 nike

我有一个 MVC 网站,该网站发布到 Azure,并在其中使用 Azure SQL 数据库。

我们需要运行计划任务来发送短信提醒。我的印象是 Azure Web Jobs 非常适合此任务,但在启动和运行它时遇到了一些问题。

我已将控制台应用添加到我的网站解决方案中,并由控制台应用中的 EF 数据模型引用(我想将其发布为 Web 作业)。

当前的控制台应用程序如下所示:

 class Program
{
static void Main(string[] args)
{
JobHost host = new JobHost();
host.RunAndBlock();
}

public static void ProcessNotifications()
{
var uow = new KirkleesDatabase.DAL.UnitOfWork();
uow.CommunicationRepository.SendPALSAppointmentReminders();
}

}

运行控制台应用程序将引发异常:

Additional information: User account connection string is missing. This can be set via the 'AzureJobsData' connection string or via the constructor.

这表明 Web 作业专门寻找指向存储帐户的连接字符串。但是,我希望 Web 作业查询 Azure 数据库而不是使用存储。

这可行吗?

谢谢

最佳答案

正如 Victor 所写,sdk 事件由 blob、队列和表触发。
满足您需求的简单解决方案:使用 pollig 方法编写控制台应用程序。无需 SDK。详情见http://blog.amitapple.com/post/73574681678/git-deploy-console-app/开头

while(true)
{
if ("isthereworktodo?")
{
var uow = new KirkleesDatabase.DAL.UnitOfWork();
uow.CommunicationRepository.SendPALSAppointmentReminders();
}
Thread.Sleep(10000); // set an appropriate sleep interval
}

关于Azure Web 作业 - 如何连接到 Azure MS SQL 数据库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21758043/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com