将应用发布到 Azure Azure App ServicePublish the App to Azure Azure App Service

作者: Mike Wassonby Mike Wasson

下载完成的项目Download Completed Project

最后一步是将应用程序发布到 Azure。As the last step, you will publish the application to Azure. 在解决方案资源管理器中,右键单击项目,然后选择 "发布"。In Solution Explorer, right-click the project and select Publish.

单击 "发布" 将调用 "发布 Web " 对话框。Clicking Publish invokes the Publish Web dialog. 如果在首次创建项目时选中了 "在云中托管",则已配置连接和设置。If you checked Host in Cloud when you first created the project, then the connection and settings are already configured. 在这种情况下,只需单击 "设置" 选项卡并选中 "执行 Code First 迁移""。In that case, just click the Settings tab and check "Execute Code First Migrations". (如果你未在云中检查 "在云中托管",请按照下一节中的步骤进行操作。)(If you didn't check Host in Cloud at the beginning, then follow the steps in the next section.)

若要部署应用,请单击 "发布"。To deploy the app, click Publish. 您可以在 " Web 发布活动" 窗口中查看发布进度。You can view the publishing progress in the Web Publish Activity window. (从 "视图" 菜单中选择 "其他窗口",然后选择 " Web 发布活动"。)(From the View menu, select Other Windows, then select Web Publish Activity.)

当 Visual Studio 完成应用程序部署时,默认浏览器会自动打开到已部署网站的 URL,你创建的应用程序现在正在云中运行。When Visual Studio finishes deploying the app, the default browser automatically opens to the URL of the deployed website, and the application that you created is now running in the cloud. 浏览器地址栏中的 URL 显示正在从 Internet 加载该站点。The URL in the browser address bar shows that the site is being loaded from the Internet.

部署到新网站Deploying to a New Website

如果在首次创建项目时未选中 "在云中托管",则可以立即配置新的 web 应用。If you did not check Host in Cloud when you first created the project, you can configure a new web app now. 在解决方案资源管理器中,右键单击项目,然后选择 "发布"。In Solution Explorer, right-click the project and select Publish. 选择 "配置文件" 选项卡,然后单击 " Microsoft Azure 网站"。Select the Profile tab and click Microsoft Azure Websites. 如果你当前未登录到 Azure,系统将提示你登录。If you aren't currently signed in to Azure, you will be prompted to sign in.

在 "现有网站" 对话框中,单击 "新建"。In the Existing Websites dialog, click New.

输入站点名称。Enter a site name. 选择 Azure 订阅和区域。Select your Azure subscription and the region. 在 "数据库服务器" 下,选择 "创建新服务器",或选择现有服务器。Under Database server, select Create New Server, or select an existing server. 单击 “创建”Click Create.

单击 "设置" 选项卡,检查 ""执行 Code First 迁移""。Click the Settings tab and check "Execute Code First Migrations". 然后单击“发布”。Then click Publish.