gpt4 book ai didi

azure - 如何部署 F# Azure WebJob?

转载 作者:行者123 更新时间:2023-12-03 01:48:07 24 4
gpt4 key购买 nike

我实际上可以将 F# 控制台应用程序部署为 Azure WebJob 吗?在 VS2017 中找不到合适的选项:(

如果可以的话,你能看一下我的代码吗?如果我将其部署为 AzureWebJob,它会按原样工作吗?我需要改变什么吗?

open FSharp.Data;
open System
open System.Net.Mail


let server = "smtp.gmail.com"
let sender = "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c0a6b3a8a1b2b0a9a5eeb3a5aea480a7ada1a9aceea3afad" rel="noreferrer noopener nofollow">[email protected]</a>"
let password = "password"
let port = 587
let SendTest email topic msg =
use msg =
new MailMessage(
sender, email, topic,
msg)
let client = new SmtpClient(server, port)
client.EnableSsl <- true
client.Timeout <- 20000
client.DeliveryMethod <- SmtpDeliveryMethod.Network
client.UseDefaultCredentials <- false
client.Credentials <- System.Net.NetworkCredential(sender, password)
client.Send msg


let metaTitle (doc:HtmlDocument) =
doc.Descendants "meta"
|> Seq.choose (fun x ->
match x.AttributeValue("name"), x.AttributeValue("property") with
| "title", _
| "headline", _
| "twitter:title", _
| _, "og:title" ->
Some(x.AttributeValue("content"))
| _, _ -> None
)

let titles (doc:HtmlDocument) =
let tagged (tag:string) =
doc.Descendants tag |> Seq.map (fun x -> x.InnerText())
Seq.concat [tagged "title"; metaTitle doc; tagged "h1"]

let title (doc:HtmlDocument) =
titles doc |> Seq.tryHead


let finalTitle (link:string) = try
link
|> HtmlDocument.Load
|> titles
|> Seq.head
with
| :? Exception as ex -> ex.Message

[<EntryPoint>]
let main argv =
let website = "website.com"
if(finalTitle website <> "expected title")
then
SendTest "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="aad8cfd9dfc6deeacdc7cbc3c684c9c5c7" rel="noreferrer noopener nofollow">[email protected]</a>" "Status: Failed" (website + " is down :( ")

0 // return an integer exit code

最佳答案

Can I actually deploy F# console app as Azure WebJob?

是的,我们可以将 F# 控制台应用部署为 Azure WebJob

Can't find a proper option in VS2017

目前不支持直接从 VS2017 工具将 F# 项目发布为 Azure Webjob。

但是我们可以从Azure Portal发布F#项目。我为它做了一个演示。以下是我的详细步骤:

1.使用VS2017创建F#项目

enter image description here

2.在项目中安装WebJob SKD

enter image description here

3.构建项目并将release或debug文件压缩到bin文件夹中

enter image description here

4.从 Azure 门户上传 Zip 文件

enter image description here

5.使用存储连接字符串配置应用程序设置

enter image description here

6.使用Azure Kudu(https://yourwebsite.scm.azurewebsites.net)工具检查webjob

enter image description here

关于azure - 如何部署 F# Azure WebJob?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43402387/

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