如何在Microsoft Azure SQL数据库中计划Sql作业? [英] How can I Schedule a Sql job in Microsoft Azure SQL database?
问题描述
我有一个SQL Agent维护工作,它检查数据库中的索引碎片,并在需要时重建索引.
I have one SQL Agent maintenance job which checks the index fragmentation within a database and rebuilds indexes if required.
这在我的测试服务器(Microsoft Sql Server 2012)中运行良好.但是我的生产服务器在Azure中.现在,我想将该作业安排到Azure.
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.
Azure SQL数据库中不存在SQL Agent,所以如何在Azure Db中安排Sql Job?
SQL Agent does not exist in Azure SQL database so how can I schedule a Sql Job in Azure Db?
推荐答案
自从首次提出此问题以来,现在有另一种替代方法可以解决此问题:
Azure功能
Since this question was first asked, there is now another alternative to handle this problem:
Azure Functions
这里有几个示例,可以轻松地对其进行修改,以调用用于重建索引的存储过程
Here are a couple of examples that could easily be modified to call a stored procedure that rebuilds your indexes
- Create a function in Azure that is triggered by a timer
- Use Azure Functions to connect to an Azure SQL Database
也可以看到
- 如何维护Azure SQL索引和统计信息-此页面提供了一个示例存储过程,用于重建您可以下载的索引.
- 重组和重建索引
- How to maintain Azure SQL Indexes and Statistics - this page has an example stored procedure for rebuilding your indexes that you can download.
- Reorganize and Rebuild Indexes
Azure函数要记住的几件事
A few things to keep in mind with Azure functions
- 它们基于Azure Web Jobs SDK构建,并提供其他功能
- 有两种不同的定价模型:
- 应用服务计划(将其附加到现有计划中)
- 可预测的成本模型
- 这会在您的网站所使用的同一台VM上增加额外的负载
- They are built on top of Azure Web Jobs SDK and offer additional functionality
- There are two different pricing models:
- App Service plan (attach it to an existing plan)
- Predictable cost model
- It puts extra load on the same VM used by your web site
- 您每个月都会得到一些免费处理
- 默认的最大运行时间为5分钟为防止计费问题,但可以通过host.json文件进行更改.
- You get some free processing every month
- The default maximum run time is 5 minutes to prevent billing problems, but it can be changed via the host.json file.
这篇关于如何在Microsoft Azure SQL数据库中计划Sql作业?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- App Service plan (attach it to an existing plan)
- 应用服务计划(将其附加到现有计划中)