简体   繁体   English

在IIS上设置Kudu

[英]Setting Up Kudu On IIS

A couple of days ago, Microsoft released the engine they're using to do git deployments to Azure . 几天前,微软发布了他们用来对Azure进行git部署的引擎 I've had a task on my TODO list for a while to get that kind of functionality set up on my DEV IIS server, so I'm interested in trying out Kudu for that purpose. 我在TODO列表上有一段时间在DEV IIS服务器上设置了这种功能,所以我有兴趣尝试Kudu。

The " Getting Started " document shows how to run the web front-end, but everything in there uses " http://localhost:PORTNUMBER " type URL's for git repositories, site URL's, etc. 入门 ”文档显示了如何运行Web前端,但其中的所有内容都使用“ http:// localhost:PORTNUMBER ”类型的URL用于git存储库,站点URL等。

I realize this is probably getting too far ahead of them, but I'm wondering if anyone has pointers for how to set it up using real domains on "regular" IIS instead of all of the localhost bits? 我意识到这可能远远超过它们,但我想知道是否有人指出如何在“常规”IIS而不是所有localhost位上使用真实域设置它?

This is an old question, so I'm giving an updated answer with more current info since I just worked through setting up Kudu on an internal deployment server. 这是一个老问题,所以我给出了更新的答案以及更多当前信息,因为我刚刚在内部部署服务器上设置了Kudu。 The currently selected answer only deals with if you are directly running Kudu from within a development environment. 当前选择的答案仅适用于您是否在开发环境中直接运行Kudu。

If you are deploying to a "production" type environment and don't want to install Visual Studio on the target server, there is a good guide on the project website on github. 如果要部署到“生产”类型环境并且不想在目标服务器上安装Visual Studio,那么github上的项目网站上有一个很好的指南。

https://github.com/projectkudu/kudu/wiki/Deploying-to-a-server https://github.com/projectkudu/kudu/wiki/Deploying-to-a-server

On the target server, you will need to install: 在目标服务器上,您需要安装:

Back on your development machine, clone the git repo and build using the "build.cmd" file, following instructions in the above link. 回到开发机器上,按照上面链接中的说明克隆git repo并使用“build.cmd”文件进行构建。

In running build.cmd I got several test failures which blocked the build from producing artifacts. 在运行build.cmd时,我遇到了几个测试失败,阻止了构建产生工件。 These were all related to Mercurial, which we don't use. 这些都与Mercurial有关,我们不使用。 Installing a Mercurial client didn't make them magically go away, so I disabled the tests rather than sink a bunch of time into debugging my environment. 安装Mercurial客户端并没有让它们神奇地消失,所以我禁用了测试而不是花费大量时间来调试我的环境。

Your build output will indicate the failures. 您的构建输出将指示失败。 I disabled by commenting out the [Fact] attribute. 我通过注释掉[Fact]属性来禁用。 These are the tests I disabled: 这些是我禁用的测试:

  • tests/Kudu.Core.Test/HgRepositoryFacts.cs (all tests) tests / Kudu.Core.Test / HgRepositoryFacts.cs(所有测试)

Once you have a successful build that has created all the items in the artifacts you can move to deploying the Kudu website and web service code. 一旦您成功构建了已创建工件中的所有项目,您就可以转移到部署Kudu网站和Web服务代码。 The below instructions are for setting up a distinct web application instance, rather than dumping everything in c:\\inetpub\\wwwroot, which is how the instructions read. 以下说明用于设置不同的Web应用程序实例,而不是将所有内容转储到c:\\ inetpub \\ wwwroot中,这是指令的读取方式。

  1. Copy "artifacts\\Release\\KuduWeb" to the target area on the server where your website will run from. 将“artifacts \\ Release \\ KuduWeb”复制到运行网站的服务器上的目标区域。 I run my kudu install with a separate host header, but you could as easily use a separate port or run as the root website. 我使用单独的主机头运行我的kudu安装,但您可以轻松地使用单独的端口或作为根网站运行。 This directory will be the root for your web application. 此目录将是Web应用程序的根目录。

  2. Create an empty "App_Data" folder immediately under the KuduWeb folder. 在KuduWeb文件夹下立即创建一个空的“App_Data”文件夹。

  3. Copy "artifacts\\Release\\SiteExtensions\\Kudu" to the same level as the folder in step 1 and rename to "Kudu.Services.Web". 将“artifacts \\ Release \\ SiteExtensions \\ Kudu”复制到与步骤1中的文件夹相同的级别,并重命名为“Kudu.Services.Web”。 This location is set as a relative path in the KuduWeb web.config file - setting serviceSitePath. 此位置设置为KuduWeb web.config文件中的相对路径 - 设置serviceSitePath。

  4. Open IIS Admin and create a website pointing to the "KuduWeb" folder from step 1. 打开IIS Admin并创建一个指向步骤1中“KuduWeb”文件夹的网站。

  5. Configure the app pool from step 4 to run as "LocalSystem". 从步骤4配置应用程序池以作为“LocalSystem”运行。 This is required to manage IIS Sites. 这是管理IIS站点所必需的。

  6. Create a new folder "apps" at the same level as KuduWeb. 在与KuduWeb相同的级别创建一个新的文件夹“apps”。 This is where deployments will be sent. 这是部署将被发送的地方。 Note: this location is controlled in the KuduWeb web.config file - setting "sitesPath" 注意:此位置在KuduWeb web.config文件中控制 - 设置“sitesPath”

  7. Change filesystem permissions to grant "Users" full access to the "apps" folder created in the above step. 更改文件系统权限以授予“用户”对上述步骤中创建的“apps”文件夹的完全访问权限。

On starting my Kudu website, I got the following error. 在启动我的Kudu网站时,我收到以下错误。

Parser Error Message: Could not load file or assembly 'System.Web.Mvc, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. 分析器错误消息:无法加载文件或程序集'System.Web.Mvc,Version = 5.1.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一。 The system cannot find the file specified. 该系统找不到指定的文件。

For some reason it didn't copy the appropriate MVC version into the deployment artifacts. 由于某种原因,它没有将适当的MVC版本复制到部署工件中。

If you hit this error, the MVC 5 file can be obtained via NuGet. 如果您遇到此错误,可以通过NuGet获取MVC 5文件。 I found that my source code was built against 5.1.0, so this is the appropriate link: 我发现我的源代码是针对5.1.0构建的,所以这是合适的链接:

https://www.nuget.org/packages/Microsoft.AspNet.Mvc/5.1.0 https://www.nuget.org/packages/Microsoft.AspNet.Mvc/5.1.0

In order to extract the dll, I set up a new dummy project and used NuGet to pull down the dll via the package manager console. 为了提取dll,我设置了一个新的虚拟项目,并使用NuGet通过包管理器控制台下拉dll。

Install-Package Microsoft.AspNet.Mvc -Version 5.1.0 安装包Microsoft.AspNet.Mvc -Version 5.1.0

Once you get the binary, copy it from package directory ( .\\packages\\Microsoft.AspNet.Mvc.5.1.0\\lib\\net45\\System.Web.Mvc.dll ) to the website bin directory on the target machine. 获得二进制文件后,将其从包目录(。\\ packages \\ Microsoft.AspNet.Mvc.5.1.0 \\ lib \\ net45 \\ System.Web.Mvc.dll)复制到目标计算机上的网站bin目录。

At this point you are up and running. 此时你已经开始运行了。 Use the web interface to create your application. 使用Web界面创建应用程序。 It will create a subfolder under the "apps" directory with a tree that should be self explanatory. 它将在“apps”目录下创建一个子文件夹,其中的树应该是自解释的。 It will also have created two new websites for your application: 它还将为您的应用程序创建两个新网站:

  • kudu_{your-app-name} kudu_ {您-APP-名}
  • kudu_service_{your-app-name} kudu_service_ {您-APP-名}

In a production situation, you should create an additional website running on appropriate port/host header that points to: .\\apps\\\\site\\wwwroot 在生产环境中,您应该创建一个在适当的端口/主机头上运行的附加网站,该网站指向:。\\ apps \\\\ site \\ wwwroot

Now you can add a git remote for your deployment. 现在,您可以为部署添加git远程。 Go to your source location in a git console (ex: Git Bash) and add the remote as identified by Kudu. 转到git控制台中的源位置(例如:Git Bash)并添加Kudu标识的遥控器。 Note: you may need to change localhost in the url to be the appropriate server name. 注意:您可能需要将URL中的localhost更改为相应的服务器名称。

git remote add deploy http://:52711/your-app-name.git git remote add deploy http://:52711 / your-app-name.git

Push your code to the new "deploy" remote and see what happens. 将您的代码推送到新的“部署”远程,看看会发生什么。 You should see all the normal push messages, plus the build output. 您应该看到所有正常的推送消息,以及构建输出。

git push deploy master git push deploy master

My initial push failed to build and deploy due to "node" not being recognized. 由于“节点”无法识别,我的初始推送无法构建和部署。 It was in the path, so a server reset convinced the path environment variable to be refreshed. 它位于路径中,因此服务器重置确信要刷新的路径环境变量。 You may find additional errors to work through. 您可能会发现其他错误。 For instance, I had an issue with MSBuild being imported and causing a hiccup. 例如,我遇到了导入MSBuild并导致打嗝的问题。

error MSB4019: The imported project "C:\\Program Files (x86)\\MSBuild\\Microsoft\\Visual Studio\\v11.0\\WebApplications\\Microsoft.WebApplication.targets" was not found. 错误MSB4019:找不到导入的项目“C:\\ Program Files(x86)\\ MSBuild \\ Microsoft \\ Visual Studio \\ v11.0 \\ WebApplications \\ Microsoft.WebApplication.targets”。

YMMV, but these are all solvable problems now. YMMV,但现在这些都是可以解决的问题。 Good continuous deploying! 良好的持续部署!

The project automatically sets up two websites on IIS for each application you add using the web front end. 对于您使用Web前端添加的每个应用程序,项目会自动在IIS上设置两个网站。 Kudu doesn't automatically map the bindings for them but it's relatively easy to open IIS and find the two sites named "kudu_appname" and "kudu_appname_service". Kudu不会自动为它们映射绑定,但是打开IIS并找到名为“kudu_appname”和“kudu_appname_service”的两个站点相对容易。 The service website is the one that you point GIT too and the other one is the site itself. 服务网站也是您指向GIT的网站,另一个是网站本身。 Just add public bindings to them by right-clicking and "edit bindings". 只需右键单击并“编辑绑定”即可向它们添加公共绑定。 You can then add public hostnames to them. 然后,您可以向它们添加公共主机名。

This is the easy part. 这是简单的部分。 The hard part that I'm still working on is getting authentication working so any random Joe isn't able to push to my kudu repository! 我仍在努力的部分是让身份验证工作,所以任何随机的Joe都无法推送到我的kudu存储库!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM