简体   繁体   English

在azure虚拟机上部署基于sql server的webservice

[英]Deploying a sql server based webservice on azure virtual machine

I have developed a web service in VS2008 in C#. 我用C#在VS2008中开发了一个Web服务。 The service queries a SQL Server Express 2012 database and returns the results. 该服务查询SQL Server Express 2012数据库并返回结果。 When I test the service on local development system it works fine. 当我在本地开发系统上测试服务时,它工作正常。

Now I have a windows azure trial account, and I want this service to be deployed on a virtual machine. 现在我有一个windows azure试用帐户,我希望将此服务部署在虚拟机上。

1- I have tried to create virtual machines with SQL server and Visual Studio on it, but could not create the service there. 1-我曾尝试使用SQL Server和Visual Studio创建虚拟机,但无法在那里创建服务。 VS does not have the Web services template there. VS没有那里的Web服务模板。

2- I have tried to create the deployment package on my dev system and tried to install the service but it also did not work. 2-我试图在我的开发系统上创建部署包并尝试安装该服务,但它也无法正常工作。

Please suggest the correct way of doing this task. 请建议正确的方法来完成这项任务。 I am very much new to all these concepts so may be I am missing some basic information and a step by step guide will not hurt. 我对所有这些概念都很陌生,所以可能是我缺少一些基本信息,一步一步的指导也不会受到伤害。

  1. Install Visual Studio 2012 Express for Web 安装Visual Studio 2012 Express for Web
  2. Get your application working in that version, and preferably upgrade it to .NET 4.5. 让您的应用程序在该版本中运行,并最好将其升级到.NET 4.5。
  3. Create a Windows Azure SQL Database by following this Getting Started guide. 按照本“入门指南”创建Windows Azure SQL数据库。
  4. Download version 4.0.15 of the SQL Azure Migration Wizard from CodePlex . 从CodePlex下载SQL Azure迁移向导的4.0.15版。
  5. Use the wizard to migrate your local database to Azure, being sure to fix all the problems it reports. 使用该向导将本地数据库迁移到Azure,确保修复它报告的所有问题。
  6. Set up a Windows Azure Web Site and publish your service to it as described in this article . 设置Windows Azure网站并按照本文所述将服务发布到该网站。

I am not sure that you did it that way, but the easiest way to create a cloud-hosted web service with MS SQL Backend would be: 我不确定您是这样做的,但使用MS SQL后端创建云托管Web服务的最简单方法是:

  1. Create a new instance of SQL Azure in Azure Management Portal . Azure管理门户中创建SQL Azure的新实例
  2. Create a new database (probably a web edition in your case). 创建一个新数据库 (可能是您的案例中的Web版本)。
  3. Use the connection string from the portal and Azure SDK to develop an ASP.NET application (web role) hosted on Azure. 使用门户网站和Azure SDK中的连接字符串开发Azure上托管的ASP.NET应用程序(Web角色)。 You can locally test this application in the similar way how you test your current ASP.NET application, provided you set up the firewall on your SQL Azure instance for inbound connections from your external IP. 如果在SQL Azure实例上为外部IP的入站连接设置防火墙,则可以使用与测试当前ASP.NET应用程序类似的方式在本地测试此应用程序。 ( here is the step-by-step tutorial for the first three steps) 是前三个步骤的分步教程)
  4. Create a new instance of cloud service in Azure management portal . 在Azure管理门户中创建新的云服务实例
  5. Deploy your application to the cloud directly from Visual Studio. 直接从Visual Studio将应用程序部署到云。 You'll, however, need at least Visual Studio 2010 and the Express Edition would already do. 但是,您至少需要Visual Studio 2010和Express Edition。

( Update: As Mark Rendle suggests in the comment and in his answer , there is no need to create a separate cloud instance as long as your service is light-weight and does only data fetching. Cloud instance would be, however, essential, if your service requires data processing or has some other logic entailing long-running processes). 更新:正如Mark Rendle在评论和他的回答中所建议的那样,只要您的服务重量轻且只提取数据,就不需要创建单独的云实例。但是,云实例是必不可少的,如果您的服务需要数据处理或具有一些需要长时间运行的逻辑。

Alternatively you might want to use Azure Mobile services , that already provide a web service for SQL Azure that might do. 或者,您可能希望使用Azure Mobile服务 ,该服务已经为SQL Azure提供了可能执行的Web服务。 This is a fully RESTful web service and you'll just need to write some logic in JavaScript, similar to Node.js implementation. 这是一个完全RESTful的Web服务,您只需要在JavaScript中编写一些逻辑,类似于Node.js实现。 See an excellent tutorial on this issue. 请参阅有关此问题的优秀教程

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

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