Deploying a sql server based webservice on azure virtual machine - c#

I have developed a web service in VS2008 in C#. The service queries a SQL Server Express 2012 database and returns the results. 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.
1- I have tried to create virtual machines with SQL server and Visual Studio on it, but could not create the service there. VS does not have the Web services template there.
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.
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.

Install Visual Studio 2012 Express for Web
Get your application working in that version, and preferably upgrade it to .NET 4.5.
Create a Windows Azure SQL Database by following this Getting Started guide.
Download version 4.0.15 of the SQL Azure Migration Wizard from CodePlex.
Use the wizard to migrate your local database to Azure, being sure to fix all the problems it reports.
Set up a Windows Azure Web Site and publish your service to it as described in this article.

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:
Create a new instance of SQL Azure in Azure Management Portal.
Create a new database (probably a web edition in your case).
Use the connection string from the portal and Azure SDK to develop an ASP.NET application (web role) hosted on Azure. 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.
(here is the step-by-step tutorial for the first three steps)
Create a new instance of cloud service in Azure management portal.
Deploy your application to the cloud directly from Visual Studio. You'll, however, need at least Visual Studio 2010 and the Express Edition would already do.
(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).
Alternatively you might want to use Azure Mobile services, that already provide a web service for SQL Azure that might do. This is a fully RESTful web service and you'll just need to write some logic in JavaScript, similar to Node.js implementation. See an excellent tutorial on this issue.

Related

Publish Azure Mobile Apps Backend

When going to publish my Mobile Service Backend there is supposed to be an option that says "Microsoft Azure App Service" but instead I get two other options: "Microsoft Azure Web Apps" & "Microsoft Azure API Apps (Preview)".
The Web Apps option identifies my service plan and SQL server but wants me to create a new mobile web app url which I already have.
Neither of these show my App Service I have already created. Is it because I don't have Azure SDK v2.9 or higher (as stated by the online resource I'm using)? When going into the NuGet Packages and it only has v2.0 for Microsoft.Windows.Azure.Server and no higher version
Anybody know how to get the higher SDK without going through VS 2015 or any other options?
According to your description, I suggest you could firstly check the existing of the mobile service resource in the VS2015 server explorer.
You could open it in the view --> server explorer.
Anybody know how to get the higher SDK without going through VS 2015 or any other options?
If this resource is existing, but the publish windows doesn't show this resource.
I suggest you could update your azure SDK(the newest is 3.0.1), you could install it in this link.
Besides, I suggest you could check you have created mobile service not web app service.

How to migrate from Microsoft SQL server database (on local machine) to LocalDB?

I have a simple web application that accesses tables in the Microsoft SQL server database installed locally on my laptop. But in order to run the application on every other laptop I have to migrate to localDB. Please suggest.!
Sorry if this is an obvious/dumb answer: The great value of web applications is that they can be accessed remotely by users who don't have to install anything to use them. Install your database and web application on a server and you can access it from anywhere.

SQL Server Reporting Services Role Via Code

I am working on a project where I'm creating an installer application to deploy Reporting Services Reports, I have currently got the reports to deploy using an RSS File, but I need to workout how I can assign a user a new role via code.
I found the answer on this website and used this example from the Microsoft website, but it seems its not supported in the Express version

Update Javascript libraries when deploying a web application to Windows Azure

I have an MVC4 web application that uses jquery and some other libs (jquery-ui in particular).
Yesterday I decided to update all the packages via NuGet package manager; my web application worked correctly on my local machine, but when I deployed it to my azure website a javascript error popped out in my browser (it was related to jquery-ui library, something like "$browser is not a function").
I searched the web and found out that the cause of this error was that I was still using an old version of jquery. It seems that deploy process didn't publish the new version of the js libraries even if they have been updated in local project.
I solved the problem connecting via RDP to the Azure machine, deleting the contents of "Scripts" folder and deploying again, but I'm wondering if there's a way to "force" script/libraries update when deploying to Azure.
Edit 1: I'm developing with Visual Studio 2012, using Mercurial as source control provider
Edit 2: I'm deploying to Azure Web Sites
Please, in your future questions clearly indicate what type of Azure Service do you use. An MVC4 web application can be deployed to 3 different type of services: Azure Web Sites, Azure Cloud Service, Azure Virtual Machine!
Since you are talking about RDP, the viable options are Cloud Service or Virtual Machine. But then you say
I solved the problem connecting via RDP to the Azure machine, deleting
the contents of "Scripts" folder and deploying again, but I'm
wondering if there's a way to "force" script/libraries update when
deploying to Azure.
Now the question is how you do deploy to Windows Azure? Is it via Visual Studio's Publish feature to Azure Cloud Service. Is it Visual Studio's Package feature and then using any other method of deployment (upload the package from the portal, use Azure PowerShell cmdlets, or use third party tool to deploy the package)? Is it integration with Mercurial and deployment is done automatically when you check-in?
Any any case, the issue you face is a mixture of NuGET failing to do real clean update of everything. Browser caching - especially for local development - IE caches all the scripts, CSS and images and it is hard to say (without explicitly deleting all locally cached files) which script are you actually using. Simple version control issue - keeping old and new scripts.
When you do a JS/CSS updates I strongly advise all the customers to first delete all browser's cache (crtl+shift+del - works for all browsers) before testing locally.
I highly doubt that if you use a Cloud Service, RDP-ing and deleting anything in the sitesroot folder will help you when you redeploy. What you do in the ROLEROOT drive (usually E:, sometimes F: drive) is dropped of/forgotten when you re-deploy regardless of the re-deploy method you use: in-place-upgrade or full re-deploy. So what you did is actually creating new package and re-deploying your new package.
The fact that you deleted some folder has no effect on your re-deploy action.

Accessing SharePoint content (list) from a WCF service

I've written a WCF service which tries to read the list items from a particular list in SharePoint. For testing purposes I run the WCF service using Visual Studio ASP.Net Development server. I pass the Site ID to the web service and from the web service I try to open the List and read the items. But when I try to read the items I'm getting the following error -
This operation can be performed only
on a computer that is joined to a
server farm by users who have
permissions in SQL Server to read from
the configuration database. To connect
this server to the server farm, use
the SharePoint Products and
Technologies Configuration Wizard,
located on the Start menu in
Administrative Tools.
Here are some facts -
I'm using SharePoint 2007 x64 in
Windows Server 2008 x64 and it is a
single server installation (no farm)
I'm a Farm administrator
I'm a System Administrator (but not
domain administrator)
I'm a SysAdmin for the SQL Server
2005 server in which is SharePoint
is having its databases
I'm the Site Collection
Administrator in which the List is
present
I opened Visual Studio 2010 as
adminsitrator
In task manager, the ASP.Net
development server process is
running under my account
I don't have any idea why I'm getting that error. Any ideas?
is the WCF service runnig on the sharepoint computer ? I bet you are trying to use the SharePoint object model outsite the sharepoint box.
If you want to access remotely to the sharepoint data, in a WCF service on your own, or actually any other program, you will have to use the Lists.asmx web service to retrieve your data from sharepoint.
In fact, in your WCF you will have to act as a client to the SP services
[edit] my bet was wrong :) here is another thing to check
Also take a look in your VS project. Setup your target platform to "AnyCpu" or "X64" to ensure the program will use the correct assemblies and registry keys.
The object model will try to open the reg key under HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node node if you process is 32 bits, instead of HKEY_LOCAL_MACHINE\SOFTWARE where the sharepoint config resides
Try to check your sharepoint application pool identity. If you, for example, trying to evelate you priviligies using RunWithEvelatedPrivilegies in your service, and app pool identity doesn't have required permissions, you will get such message.
Okie. I found the issue. It is related to the same problem which I've been facing since I switched to x64 development in SharePoint 2007. When I deployed the WCF service to IIS everything worked fine.
Using Visual Studio 2010 (no matter what my target platform of my project is) I've never been able to access SharePoint content through a simple console application or a simple asp.net web application. I've clearly understood that the problem is with the x86 x64 stuffs and I've not been able to resolve it till now. I've been haunted by this for so long now.
If you have any comments on this answer please post it.
Old Ref - Filenotfound exception while opening an SPSite object - x64

Categories

Resources