git commit #_使用Git和Deploy按钮在Azure Web Apps中使用FAKE运行Suave.io和F#

git commit #

git commit #

I was told by some lovely folks in the F# community that there is a nice web framework called Suave.io. Best name ever, eh? Suave is a clean, lightweight, and very F#y (pronounced F-Sharp-ie, I say) in its syntax.

F#社区的一些可爱的人告诉我,有一个很好的Web框架,称为Suave.io 。 有史以来最好的名字,是吗? Suave的语法干净,轻巧,非常F#y(我说是F-Sharp-ie)。

Frameworks like this do well when they are easy to deploy, especially for Hello World. I always find that if a framework can quickly and easily give me a sense of accomplishment I'll be more likely to stick with it. I like to "fall into the pit of success."

这样的框架在易于部署时效果很好,尤其是对于Hello World。 我总是发现,如果一个框架能够快速,轻松地给我一种成就感,我将更有可能坚持下去。 我喜欢“陷入成功之坑”。

I wanted to see if I could make Suave on Azure work easily as well. With the help of Steffen Forkman and the encouragement of the F# community (who have felt historically that support for F# in Visual Studio and Azure has been lacking) I put this little proof of concept together. I used the HttpPlatformHandler that is available in Azure Web Apps now by default, along with a basic Kudu Deployment Script from my Ruby/Middleman post.

我想看看是否也可以使Suave on Azure轻松工作。 在Steffen Forkman的帮助下以及F#社区的鼓励(历史上一直认为Visual Studio和Azure中缺少对F#的支持),我将这一点概念证明放在一起了。 我使用了默认情况下现在默认在Azure Web Apps中可用的HttpPlatformHandler ,以及我的Ruby / Middleman帖子中基本Kudu部署脚本

Most of the F# community uses a NuGet alternative called Paket that is more F#-friendly. There's also a tiny Paket.Bootstrapper so I could curl things down, then run Paket like this, as part of an Azure Web App deployment. This script modified from Steffen:

大多数F#社区都使用一个名为Paket的NuGet替代方案,它对F#更为友好。 还有一个很小的Paket.Bootstrapper,因此我可以缩小内容,然后像这样运行Paket,作为Azure Web App部署的一部分。 这个脚本是从Steffen修改而来的

@echo off
cls

mkdir .paket
REM TODO - might want to do an IF EXISTS *or* a SHA check
curl https://github.com/fsprojects/Paket/releases/download/1.2.0/paket.bootstrapper.exe -L --insecure -o .paket\paket.bootstrapper.exe

.paket\paket.bootstrapper.exe prerelease
if errorlevel 1 (
exit /b %errorlevel%
)

.paket\paket.exe restore
if errorlevel 1 (
exit /b %errorlevel%
)

Then we need web.config to tell Azure Web Apps (IIS8+) to start FAKE to get F# and Suave going. Note the use of %HOME%, full paths and the %HTTP_PLATFORM_PORT%:

然后,我们需要web.config来告诉Azure Web Apps(IIS8 +)启动FAKE以使F#和Suave正常运行。 注意使用%HOME%,完整路径和%HTTP_PLATFORM_PORT%:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<remove name="httpplatformhandler" />
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform stdoutLogEnabled="false" stdoutLogFile="fake.log" startupTimeLimit="20" processPath="%HOME%\site\wwwroot\packages\FAKE\tools\FAKE.exe"
arguments="%HOME%\site\wwwroot\build.fsx port=%HTTP_PLATFORM_PORT%">
<environmentVariables>
<environmentVariable name="WhateverYouLike" value="GoesHere"/>
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>

I added logging but it's off by default. You can use it to debug if you have issues, as the FAKE.exe output will go into a series of log files. You can then access them with the Kudu debug console.

我添加了日志记录,但默认情况下处于关闭状态。 如果有问题,可以使用它进行调试,因为FAKE.exe输出将进入一系列日志文件。 然后,您可以使用Kudu调试控制台访问它们。

I like running "azure site log tail YOURSITE" with the Azure Cross Platform command line. It lets me see the deployment and output as it happens.

我喜欢使用Azure Cross Platform命令行运行“ azure网站日志尾巴YOURSITE”。 它使我可以实时查看部署和输出。

FAKE and F# in Azure Web Apps

Here is Steffen's build.fsx:

这是Steffen的build.fsx:

// --------------------------------------------------------------------------------------
// FAKE build script
// --------------------------------------------------------------------------------------

#r @"packages/FAKE/tools/FakeLib.dll"

open System
open System.IO
open Fake

Environment.CurrentDirectory <- __SOURCE_DIRECTORY__

// Step 2. Use the packages

#r "packages/Suave/lib/net40/Suave.dll"

open Suave // always open suave
open Suave.Http.Successful // for OK-result
open Suave.Web // for config
open Suave.Types
open System.Net

let port = Sockets.Port.Parse <| getBuildParamOrDefault "port" "8083"

let serverConfig =
{ defaultConfig with
bindings = [ HttpBinding.mk HTTP IPAddress.Loopback port ]
}

startWebServer serverConfig (OK "Hello World! It's Suave.io on Azure Websites. <a href='https://github.com/shanselman/suavebootstrapper'>So easy to setup. Just click Deploy.</a>")

I just added the Azure Deploy button to my Readme.md like this. This is markdown, of course, but could be HTML

我只是这样向我的Readme.md添加了Azure Deploy按钮。 当然,这是减价,但可以是HTML

[![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://azuredeploy.net/)

And you can try this yourself by visiting the repository here and pressing Deploy to Azure, or hit it here:

您可以通过访问此处的存储库并按Deploy到Azure,或在此处进行访问来自己尝试:

Hopefully this is a decent clear start towards easily deploying F# Web Apps to Azure via Git, and/or the Deploy Button.

希望这是通过Git和/或“部署按钮”轻松将F#Web Apps轻松部署到Azure的良好起点。

Your thoughts?

你的想法?

翻译自: https://www.hanselman.com/blog/running-suaveio-and-f-with-fake-in-azure-web-apps-with-git-and-the-deploy-button

git commit #

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值