如何在 Microsoft Azure SQL 数据库中安排 Sql 作业?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27309474/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 03:02:06  来源:igfitidea点击:

How can I Schedule a Sql job in Microsoft Azure SQL database?

sqlsql-serverazure-sql-databasesql-job

提问by user1006544

I have one SQL Agent maintenance job which checks the index fragmentation within a database and rebuilds indexes if required.

我有一项 SQL 代理维护工作,它检查数据库中的索引碎片并在需要时重建索引。

This is running well in my test server (Microsoft Sql Server 2012). But my production server is in Azure. Now I want to schedule that job to Azure.

这在我的测试服务器(Microsoft Sql Server 2012)中运行良好。但是我的生产服务器在 Azure 中。现在我想将该作业安排到 Azure。

SQL Agent does not exist in Azure SQL database so how can I schedule a Sql Job in Azure Db?

Azure SQL 数据库中不存在 SQL 代理,那么如何在 Azure Db 中安排 Sql 作业?

回答by David Yates

Since this question was first asked, there is now another alternative to handle this problem:
Azure Functions

由于这个问题是第一次被问到,现在有另一种方法来处理这个问题:
Azure Functions

Here are a couple of examples that could easily be modified to call a stored procedure that rebuilds your indexes

下面是几个可以轻松修改以调用重建索引的存储过程的示例

Also see

另见

A few things to keep in mind with Azure functions

有关 Azure 函数的一些注意事项

回答by Dunc

This feature has been rejected by Microsoft, see here.

此功能已被 Microsoft 拒绝,请参阅此处

To quote the post:

引用帖子:

Today in Azure there are several alternatives,

1) SQL Database Elastic Jobs http://azure.microsoft.com/en-us/documentation/articles/sql-database-elastic-jobs-overview/

2) The Azure job scheduler http://www.windowsazure.com/en-us/services/scheduler/

3) The new preview of Azure Automation http://azure.microsoft.com/en-us/services/automation/.

4) SQL Server in a VM

今天在 Azure 中有几种选择,

1) SQL 数据库弹性作业 http://azure.microsoft.com/en-us/documentation/articles/sql-database-elastic-jobs-overview/

2) Azure 作业调度程序 http://www.windowsazure.com/en-us/services/scheduler/

3) Azure 自动化的新预览 http://azure.microsoft.com/en-us/services/automation/

4) 虚拟机中的 SQL Server

Option 1 requires an additional dedicated cloud service, which increases cost. Option 2 is free (I think) as long as you don't run more than once per hour.

选项 1 需要额外的专用云服务,这会增加成本。只要您每小时不超过一次运行,选项 2 是免费的(我认为)。

回答by b2zw2a

Azure SQL does not support sql jobs. From documentation:

Azure SQL 不支持 sql 作业。从文档

Microsoft Azure SQL Database does not support SQL Server Agent or jobs. You can, however, run SQL Server Agent on your on-premise SQL Server and connect to Microsoft Azure SQL Database.

Microsoft Azure SQL 数据库不支持 SQL Server 代理或作业。但是,您可以在本地 SQL Server 上运行 SQL Server 代理并连接到 Microsoft Azure SQL 数据库。

WebJobs: If you have a website you can create webjob and run it on schedule. See more here

WebJobs:如果你有一个网站,你可以创建 webjob 并按计划运行它。在这里查看更多

Other alternatives - Scheduling job on SQL Azure

其他替代方案 -在 SQL Azure 上调度作业

回答by Rolf Schouteten

You can use Azure automation to schedule jobs on an Azure-DB like the on premise SQL Agent.

可以使用 Azure 自动化在 Azure-DB 上安排作业,如本地 SQL 代理。

See https://azure.microsoft.com/nl-nl/blog/azure-automation-your-sql-agent-in-the-cloud/for more information.

有关详细信息,请参阅https://azure.microsoft.com/nl-nl/blog/azure-automation-your-sql-agent-in-the-cloud/

回答by jrummell

Another option is rovergo, a service that allows you to schedule sql jobs with a cron expression. This is nice because you don't have to create a web job or azure function. You can simply schedule a sql script.

另一种选择是rovergo,该服务允许您使用 cron 表达式安排 sql 作业。这很好,因为您不必创建 Web 作业或 azure 函数。您可以简单地安排一个 sql 脚本。

(I'm a developer on rovergo)

(我是 rovergo 的开发人员)