配置运行环境

创建Web应用

In the Visual Studio Start Page, tap New Project....

在Visual Studio启示页面,点击New Project…

Alternatively, you can use the menus to create a new project. Tap File > New > Project....

你也可以通过菜单来创建一个新的项目。点击File > New > Project…

Complete the New Project dialog:

完成新项目的创建

  • In the left pane, tap Web

  • 在左边面板,点击Web

  • In the center pane, tap ASP.NET Core Web Application (.NET Core)

  • 在中间的面板,点击选择Asp.Net Core Web Application(.Net Core)

  • Tap OK

  • 点击OK

In the New ASP.NET Core Web Application (.NET Core) dialog:

在New Asp.Net Core Web Application(.Net Core)对话框中:

  • Tap Web Application

  • 点击Web Application

  • Verify Authentication is set to Individual User Accounts

  • Authentication设置成Individual User Accounts

  • Verify Host in the cloud is not checked

  • 不选中Host in the Cloud

  • Tap OK

  • 点击OK

在本地测试应用

  • Press Ctrl-F5 to run the app locally

  • 按Ctrl+F5在本地运行应用

  • Tap the About and Contact links. Depending on the size of your device, you might need to tap the navigation icon to show the links

  • 点击About和Contact链接,根据你设备分辨率的大小,你可能需要点击导航图标才能看到这些链接。

  • Tap Register and register a new user. You can use a fictitious email address. When you submit, you'll get the following error:
  • 点击注册链接注册一个新的用户。你可以输入虚拟的Email地址,当你点击提交的时候,你会看到错误:

You can fix the problem in two different ways:

你可以使用以下两种方式修复问题:

  • Tap Apply Migrations and, once the page updates, refresh the page;

  • 点击Apply Migrations,等待更新后,刷新页面

  • Run the following from a command prompt in the project's directory:

  • 在命令终端下,到项目目录运行以下命令:

dotnet ef database update

The app displays the email used to register the new user and a Log off link.

刷新页面后,页面会显示我们注册的新用户和看到一个Log off的链接。

应用部署到Azure

Right-click on the project in Solution Explorer and select Publish....

在Solution Explorer右键项目,点击Publish

In the Publish dialog, tap Microsoft Azure App Service.

在Publish对话框中,点击Microsoft Azure App service.

Tap New... to create a new resource group. Creating a new resource group will make it easier to delete all the Azure resources you create in this tutorial.

点击New创建一个新的资源组。创建新的资源组可以方便你删除所有在Azure上创建的范例资源。

Create a new resource group and app service plan:

添加一个新的Resource group和app service plan:

  • Tap New... for the resource group and enter a name for the new resource group

  • 在resource group点击New,然后为这个资源组取名

  • Tap New... for the app service plan and select a location near you. You can keep the default generated name

  • 在app service plan点击New,选择一个

  • Tap Explore additional Azure services to create a new database

  • 点击Explore additional Azure services去创建一个新的数据库

  • Tap the green + icon to create a new SQL Database

  • 点击绿色的加号图标创建一个新的Sql数据库

  • Tap New... on the Configure SQL Database dialog to create a new database server.

  • 在Configure Sql Database对话框中点击New创建一个新的数据库

  • Enter an administrator user name and password, and then tap OK. Don't forget the user name and password you create in this step. You can keep the default Server Name

  • 输入一个管理员名和密码,点击OK。不要忘记你设置的用户名和密码。ServerName可以保持默认的。

  • Tap OK on the Configure SQL Database dialog

  • 在Configure SQL Database对话框点击OK

  • Tap Create on the Create App Service dialog

  • 在Creat App Service对话框点击Create

  • Tap Next in the Publish dialog

  • 在Publish对话框点击Next

  • On the Settings stage of the Publish dialog:

  • 点击Publish对话框的Settings标签

    • Expand Databases and check Use this connection string at runtime

    • 扩展Databases,选中Use this connection string at runtime

    • Expand Entity Framework Migrations and check Apply this migration on publish

    • 扩展Entity Framework Migrations,选中Apply this migration on publish

  • Tap Publish and wait until Visual Studio finishes publishing your app

  • 点击Publish,等待Visual Studio完成发布你的应用。

Visual Studio will publish your app to Azure and launch the cloud app in your browser.

Visual Studio会在发布到Azure后通过浏览器打开你在云端部署的应用。

在Azure上测试你的应用

  • Test the About and Contact links

  • 测试About和Contact链接

  • Register a new user

  • 注册一个用户

更新应用

  • Edit the Views/Home/About.cshtml Razor view file and change its contents. For example:

  • 编辑Views/Home/About.cshtml文件,修改它。参考:
@{
ViewData["Title"] = "About";
}
<h2>@ViewData["Title"].</h2>
<h3>@ViewData["Message"]</h3> <p>My updated about page.</p>
  • Right-click on the project and tap Publish... again

  • 再次右键项目点击Publish

  • After the app is published, verify the changes you made are available on Azure

  • 发布后,检查下在Azure端的应用是否改变

清除应用

When you have finished testing the app, go to the Azure portal and delete the app.

当你完成测试后,去Azure后台删除这个应用。

  • Select Resource groups, then tap the resource group you created

  • 选择Resource groups,然后选中你创建的资源组

  • In the Resource group blade, tap Delete

  • 在Resource group选项卡中,点击Delete

  • Enter the name of the resource group and tap Delete. Your app and all other resources created in this tutorial are now deleted from Azure

  • 输入资源组名点击Delete。你的应用和创建的资源在Azure中将会被删除。

原文链接

https://docs.microsoft.com/zh-cn/aspnet/core/tutorials/publish-to-azure-webapp-using-vs

【翻译】使用Visual Studio在Azure上部署Asp.Net Core Web应用的更多相关文章

  1. 在 Azure 上部署 Asp.NET Core Web App

    在云计算大行其道的时代,当你要部署一个网站时第一选择肯定是各式各样的云端服务.那么究竟使用什么样的云端服务才能够以最快捷的方式部署一个 ASP.NET Core的网站呢?Azure 的 Web App ...

  2. Visual Studio Code和Docker开发asp.net core和mysql应用

    Visual Studio Code和Docker开发asp.net core和mysql应用 .net猿遇到了小鲸鱼,觉得越来越兴奋.本来.net猿只是在透过家里那田子窗看外面的世界,但是看着海峡对 ...

  3. CentOS7上部署ASP.Net Core 2.2应用

    前言 在CentOS7上部署ASP.Net Core应用是我的技术路线验证的一部分,下一个产品计划采用ASP.Net Boilerplate Framework开发.因此需要求提前进行一下技术验证,在 ...

  4. Web Server 在IIS上部署ASP.NET Core项目

    在IIS上部署ASP.NET Core项目 一.配置应用程序池为无托管: 二.安装ASPNETCoreModule:(核心) 下载地址:https://go.microsoft.com/fwlink/ ...

  5. .NET开发框架(五)-IIS上部署ASP.NET Core项目教程

    系列教程:从初学者到架构师的一步步蜕变 本篇经验将和大家介绍如何在IIS上部署ASP.NET Core项目,希望对初学.NET CORE的童靴入门有所帮助! 1.打开VS,创建项目,选择ASP.NET ...

  6. 在Azure上部署Windows Server Core

    作为服务器操作系统,图形界面真心有些多余了,这也是很多人喜欢Linux服务器的原因之一.从Windows Server 2008开始,微软提供了Server Core版本,其实就是一个没有图形界面的服 ...

  7. Azure 部署 Asp.NET Core Web App

    在云计算大行其道的时代,当你在部署一个网站时,第一选择肯定是各式各样的云端服务.那么究竟使用什么样的云端服务才能够以最快捷的方式部署一个 ASP.NET Core 的网站呢?Azure 的 Web A ...

  8. Gitlab CI 自动部署 asp.net core web api 到Docker容器

    为什么要写这个? 在一个系统长大的过程中会经历不断重构升级来满足商业的需求,而一个严谨的商业系统需要高效.稳定.可扩展,有时候还不得不考虑成本的问题.我希望能找到比较完整的开源解决方案来解决持续集成. ...

  9. docker4dotnet #3 在macOS上使用Visual Studio Code和Docker开发asp.net core和mysql应用

    .net猿遇到了小鲸鱼,觉得越来越兴奋.本来.net猿只是在透过家里那田子窗看外面的世界,但是看着海峡对岸的苹果园越来越茂盛,实在不想再去做一只宅猿了.于是,.net猿决定搭上小鲸鱼的渡轮到苹果园去看 ...

随机推荐

  1. 热门IOS 第三方库

    综合github上各个项目的关注度与具体使用情况,涵盖功能,UI,数据库,自动化测试,编程工具等类型,看完,还敢自称”精通iOS开发”吗? https://github.com/syedhali/EZ ...

  2. 转:web_submit_data函数

    web_submit_data函数处理无状态或者上下文无关的表单提交.它用来生成表单的GET或POST请求,这些请求与Form自动生成的请求是一样的.发送这些请求时不需要表单上下文. 函数语法:Int ...

  3. Python3基础 list() 将一个元组转换成列表

    镇场诗: 诚听如来语,顿舍世间名与利.愿做地藏徒,广演是经阎浮提. 愿尽吾所学,成就一良心博客.愿诸后来人,重现智慧清净体.-------------------------------------- ...

  4. java中的装饰设计模式,浅谈与继承之间的区别

    最初接触装饰设计模式,一直搞不懂这么做的意义是什么,看了网上很多的资料,对于与继承的区别并没有很清楚的分析,直到看到这篇博客:http://www.cnblogs.com/rookieFly-tdii ...

  5. kindeditor集成ckplayer(带右键编辑菜单)

    相信好多朋友为开源web编辑器没有集成视频播放器而烦恼,于是我就是试着修改了一下kindeditor,其实ueditor应该也是同样的,好了不多说了直接上图吧 kindeditor版本: 4.1.7  ...

  6. js url编码函数

    JavaScript中有三个可以对字符串编码的函数,分别是: escape,encodeURI,encodeURIComponent,相应3个解码函数:unescape,decodeURI,decod ...

  7. js删除最后一个字符串方法

    JS 删除字符串最后一个字符的几种方法 2010-12-02 08:18:35|  分类: 编程 |举报 |字号 订阅   字符串:string s = "1,2,3,4,5," ...

  8. hibernate--一对多单向关联 (重点!!!)

    多对一是在多的类上存在一的对象 一对多是在一的类上存在多的集合. 多的类 user.java: package com.bjsxt.hibernate; import javax.persistenc ...

  9. highcharts分段显示不同颜色

    最近在做统计图的时候,碰到一个需求 类似如下: 就是在红色虚线框内的折线在不同区域用不同的颜色表示,并且是虚线. 开始定位为用highcharts库实现.确定用这个库后,开始在网上查资料,发现有类似的 ...

  10. 使用maven管理后,依然找不到需要的jar包

    使用maven管理后,依然报错,找不到,比如如下错误java.lang.ClassNotFoundException: org.springframework.web.context.ContextL ...