Geeks With Blogs
Magnus Karlsson
Update Oct. 29 2012: Got a question about how to upload Certificate files. See part 4 for instructions.

I aim at keeping this blog post updated and add related posts to it. Since there are a lot of these out there I link to others that has done kind of the same before me, kind of a blog-DRY pattern that I'm aiming for. I also keep all mistakes and misconceptions for others to see. As an example; if I hit a stacktrace I will google it if I don't directly figure out the reason for it. I will then probably take the most plausible result and try it out. If it fails because I misinterpreted the error I will not delete it from the log but keep it for future reference and for others to see. That way people that finds this blog can see multiple solutions for indexed stacktraces and I can better remember how to do stuff. To avoid my errors I recommend you to read through it all before going from start to finish.
The steps:
  1. Setup project in VS2012. (msdn blog)
  2. Setup Azure Services (half of mpspartners.com blog)
  3. Setup connections strings and configuration files (msdn blog + notes)
  4. Export certificates.
  5. Create Azure package from vs2012 and deploy to staging (same steps as for production).
  6. Connections string error

 

  1. Set up the visual studio project:
http://blogs.msdn.com/b/avkashchauhan/archive/2011/11/08/developing-asp-net-mvc4-based-windows-azure-web-role.aspx


 2. Then login in to Azure to setup the services:
Stop following this guide at the "publish website" part since we'll be uploading a package.
http://www.mpspartners.com/2012/09/ConfiguringandDeployinganMVC4applicationasaCloudServicewithAzureSQLandStorage/


 3. When set up (connection strings for debug and release and all), follow this guide to set up the configuration files:
http://msdn.microsoft.com/en-us/library/windowsazure/hh369931.aspx

Trying to package our application at this step will generate the following warning:
3>MvcWebRole1(0,0): warning WAT170: The configuration setting 'Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString' is set up to use the local storage emulator for role 'MvcWebRole1' in configuration file 'ServiceConfiguration.Cloud.cscfg'. To access Windows Azure storage services, you must provide a valid Windows Azure storage connection string.


 

Right click the web role under roles in solution manager and choose properties. Choose "Service configuration: Cloud". At "specify storage account credentials" we will copy/paste our account name and key from the Azure management platform.
3.1 

4. Right-click the Cloud Project(called BIAB in the screen shot). 
Click "Remote desktop Configuration". In the Remote desktop configuration window, 
Click the "View..." button next to drop down list. I have two certificates in my drop down list. Remember the name of the certificate selected in the list since you might wanna name the file youre exporting to something similar at the end of the process. You will do this this procedure for each certificate you are using. Clicking "View..." will open a new window named "Certificate". 
In this window, click the "Copy to file..." button in the down right area of the window. 
Select "Yes, export private key" and click next. 
Keep the suggesed export format and click next. Name the certificate and choose browse to save it somewhere you'll find it from the portal manager later. 
Finally, click "Finish". Now do this again for your other certificates before we go to the Portal manager.

4.1


When the certificates saved to files we can go to the portal manager to upload them to our Cloud Service. 
In portal manager: Click "Cloud Services in the left menu. Select your Cloud Service. Choose staging or production depending of the wnvironment you are configuring. In the top menu to the right. Select certificates. Choose upload in the bottom menu and browse for your certificates to upload them. Done.

5 Now right click the cloud project and select package.

5.1 Showing dialogue box.



 

5.2 Package success



 

Now copy the path to the packaged file and go to management portal again. 
Click your web role and choose staging (or production). Upload. 
5.3


Tick the box about the single instance if that's what you want or you don't know what it means. Otherwise the following will happen (see image 4.6)
5.4 Dialogue box



 

When you have clicked the symbol for accept- button you will see the following screen with some green indicators down at the right corner. Click them if you want to see status.
5.5 Information screen.


5.6 
"Failed to deploy application. 
The upload application has at least one role with only one instance. We recommend that you deploy at least two instances per role to ensure high availability in case one of the instances becomes unavailable. "
To fix, go to step 5.4



If you forgot to (or just didn't know you were supposed to) export your certificates. The following error will occur. 
Side note, the following thread suggests. To prevent: "Enable Remote Desktop for all roles" when right-clicking BIAB and choosing "Package". But in my case it was the not so present certificates. I fund the solution here.
http://social.msdn.microsoft.com/Forums/en-US/dotnetstocktradersampleapplication/thread/0e94c2b5-463f-4209-86b9-fc257e0678cd
5.7



5.8 Success! 


5.9 Nice URL n' all. (More on that at another blog post).

6. If you try to login and get



When this error occurs many web sites suggest this is because you need:http://nuget.org/packages/Microsoft.AspNet.Providers.LocalDB

Or : http://nuget.org/packages/Microsoft.AspNet.Providers

But it can also be that you don't have the correct setup for converting connectionstrings between your web.config to your debug.web.config(or release.web.config, whichever your using).
Run as suggested in the "ordinary project in your solution.

So, hope you find my notes useful and please feel free to send more emails but I would really prefer if you wrote any questions here directly since the answers would benefit other visitors as well then. Happy coding!
 


 


 


 


 

Posted on Wednesday, October 17, 2012 1:13 PM Azure Web Roles | Back to top


Comments on this post: Setup and configure a MVC4 project for Cloud Service(web role) and SQL Azure

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Magnus Karlsson | Powered by: GeeksWithBlogs.net