[英]How to run a Python script in Azure
I have a Python script that gets data from Azure Event Hub and saves in into an Azure Cosmos DB database.我有一个 Python 脚本,它从 Azure 事件中心获取数据并保存到 Azure Cosmos DB 数据库中。 I currently run this script on a local machine but I'd like to run the script in my companies Azure account.
我目前在本地机器上运行此脚本,但我想在我的公司 Azure 帐户中运行该脚本。 What Azure service could / should I use to run this script permanently?
我可以/应该使用什么 Azure 服务来永久运行此脚本?
By 'permanently' I mean that I don't want to use any kind of triggers or other options provided by the Azure Function App because I want it to run non-stop. “永久”是指我不想使用 Azure Function App 提供的任何类型的触发器或其他选项,因为我希望它不间断地运行。
Usually Azure functions can run continuously until the messages are stopped.通常,Azure 函数可以持续运行,直到消息停止。
Else as you mentioned apart from functions, We can run a script non stop with help of webjob in Azure App service.除此之外,除了功能之外,我们还可以在 Azure App 服务中的 webjob 的帮助下不间断地运行脚本。 Here we will be having two types of webjob:
在这里,我们将有两种类型的 webjob:
Triggered: This will run the script based on a trigger.触发:这将基于触发器运行脚本。
Continuous: This will run until the job is completed.连续:这将一直运行到作业完成。
Continuous WebJob runs on all instances that the web app runs on.连续 Web 作业在 Web 应用程序运行的所有实例上运行。 You can optionally restrict the WebJob to a single instance.
您可以选择将 WebJob 限制为单个实例。
Also our code will be deployed under \\site\\wwwroot\\app_data\\Jobs\\Continuous
.此外,我们的代码将部署在
\\site\\wwwroot\\app_data\\Jobs\\Continuous
。
Find the below screenshot for its differences:查找以下屏幕截图以了解其差异:
Below are the steps about the creation:下面是关于创建的步骤:
Azure Portal -> App Service Web App. Azure 门户 -> 应用服务 Web 应用。
In the left pane we will find WebJobs.在左窗格中,我们将找到 WebJobs。
Add a new WebJob and attach the script under File Upload.添加一个新的 Web 作业并在文件上传下附加脚本。
Check for the rest of the configurations from MS Docs .检查MS Docs 中的其余配置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.