如何部署 F# Azure WebJob?
How do I Deploy F# Azure WebJob?
我真的可以将 F# 控制台应用部署为 Azure WebJob 吗?在 VS2017 中找不到合适的选项:(
如果可能的话,你能看看我的代码吗?如果我将它部署为 AzureWebJob,它会像现在这样工作吗?我需要改变什么吗?
open FSharp.Data;
open System
open System.Net.Mail
let server = "smtp.gmail.com"
let sender = "fsharpie.send@gmail.com"
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 "result@gmail.com" "Status: Failed" (website + " is down :( ")
0 // return an integer exit code
您需要从您的 f# 代码创建一个 .exe,从输出文件夹创建一个 zip 并将其上传到 Azure。
https://blogs.msdn.microsoft.com/dave_crooks_dev_blog/2015/02/18/deploying-f-web-job-to-azure/
另一种选择是使用 Azure Functions,它是 Azure WebJobs 的演变并支持 f#:https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-fsharp
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 发布 F# 项目 Portal.I 为它做了一个演示。以下是我的详细步骤:
1.Create 使用 VS2017 的 F# 项目
2.Install项目中的WebJob SKD
3.Build 项目并将发布或调试文件压缩到 bin 文件夹中
4.Upload 来自 Azure 门户的 Zip 文件
5.Config Appsetting with Storage 连接字符串
6.Check 使用 Azure Kudu(https://yourwebsite.scm.azurewebsites.net) 工具的网络作业
我真的可以将 F# 控制台应用部署为 Azure WebJob 吗?在 VS2017 中找不到合适的选项:(
如果可能的话,你能看看我的代码吗?如果我将它部署为 AzureWebJob,它会像现在这样工作吗?我需要改变什么吗?
open FSharp.Data;
open System
open System.Net.Mail
let server = "smtp.gmail.com"
let sender = "fsharpie.send@gmail.com"
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 "result@gmail.com" "Status: Failed" (website + " is down :( ")
0 // return an integer exit code
您需要从您的 f# 代码创建一个 .exe,从输出文件夹创建一个 zip 并将其上传到 Azure。
https://blogs.msdn.microsoft.com/dave_crooks_dev_blog/2015/02/18/deploying-f-web-job-to-azure/
另一种选择是使用 Azure Functions,它是 Azure WebJobs 的演变并支持 f#:https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-fsharp
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 发布 F# 项目 Portal.I 为它做了一个演示。以下是我的详细步骤:
1.Create 使用 VS2017 的 F# 项目
2.Install项目中的WebJob SKD
3.Build 项目并将发布或调试文件压缩到 bin 文件夹中
4.Upload 来自 Azure 门户的 Zip 文件
5.Config Appsetting with Storage 连接字符串
6.Check 使用 Azure Kudu(https://yourwebsite.scm.azurewebsites.net) 工具的网络作业