我可以将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
答案 0 :(得分:1)
您需要从f#代码创建.exe,从输出文件夹创建一个zip并将其上传到Azure。
https://blogs.msdn.microsoft.com/dave_crooks_dev_blog/2015/02/18/deploying-f-web-job-to-azure/
另一个选择是使用Azure功能,这是Azure WebJobs的发展,并支持f#:https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-fsharp
答案 1 :(得分:1)
我可以将F#控制台应用实际部署为Azure WebJob吗?
是的,我们可以将F#控制台应用程序作为Azure WebJob
进行部署在VS2017中找不到合适的选项
目前不支持直接从VS2017工具发布F#项目作为Azure webjob。
但是我们可以从Azure Portal发布F#项目。我做了一个演示。以下是我的详细步骤:
1.使用VS2017创建F#项目
2.在项目中安装WebJob SKD
3.建立项目并将发布或调试文件压缩到bin文件夹
4.从Azure门户
上载Zip文件5.配置Appsetting with Storage连接字符串
6.使用Azure Kudu(https://yourwebsite.scm.azurewebsites.net)工具检查webjob