Azure Web Role - Multiple websites don't compile when debugger is run in Visual Studio - debugging

I have an Azure Cloud Service Project that has a web role with multiple websites associated with it.
When I click the "run" button, it fails to load the debug symbols for all the websites in the web role. In order to debug the other websites, I have to explicitly build the web project in question before I can run the debugger.
How can I configure the Azure Cloud Service Project to compile all the associated webs within a single web role?

As of this posting, Visual Studio 2012 support for multiple websites within a single web role is fairly poor (Exibit A, Exibit B).
When you click the "Run" button in a solution, it doesn't mean that all projects will be compiled. Only those directly related with the project that is being run at the moment will be compiled (and debug symbols updated).
Consider the following work-around:
Identify the main web role web project in the solution (it should the one that
matches the name of the web role in the Azure Cloud Service Project).
Right click on the web project
Go to "Add Reference"
Go to "Solution"->"Projects"
Check the checkbox next to each of the web role's associated websites.
Click OK
By adding a reference to the other web projects, it causes the compiler to compile the other webs when the Azure Cloud Service Project is run with the debugger.
This will allow you once again hit the "run" button with great abandon.

I've posted some details on using multiple web sites within a web role on my blog at http://michaelcollier.wordpress.com/2013/01/14/multiple-sites-in-a-web-role/.
As for the debugger, are you using host headers for the different sites? If so, try switching to use different ports instead. I've had better luck going that route for debugging purposes. Then switch back to host headers when ready to deploy.

Related

How to Publish .Net solution containing multiple projects through Visual Studio to Azure

I'm having a .Net Solution with 2 Projects. I've created a webapp in azure for deployment. So, i downloaded publishsetting file from Azure webapp.
Is there anyway to publish the entire solution[multiple projects] to that webapp using downloaded publishsettings file.
I see that only one project can be published to azure. Please suggest
Hosting on the same Azure Web App with different slots
First, you'll need to define your second slot. This can be done in the portal by navigating to your Web App's management blade, then clicking the Deployment Slots menu option. Once a slot is defined, you can click on it under the Deployment Slots menu, and you'll be taken to a totally separate Overview tab for the slot. Note that on this page, you can download a totally separate Publish Profile for the slot.
With two web applications in the same Visual Studio solution, you can right click on each, choose "Publish", then use a primary or slot publish profile to determine where each web application will be published.
Multiple custom domain names for different web applications in one Azure Web App
Use the same steps as above. After publishing both of your sites (using two slots - the primary and the new slot you define), browse to the Custom Domains tab in each slot. Here, you can set up each custom domain so that Azure will route traffic to the appropriate slot accordingly.

Deploying VirtoCommerce.Manager to Azure from Visual Studio

I am working with Virto Commerce server 2.4.561 and I'm having a great deal of difficulty successfully publishing to Azure from Visual Studio. Based on the documentation provided, it's not clear to me what the appropriate method is. Most guidance related to Azure assumes that I am using Git deployment. But in this case I am not. I am coding locally on my dev machine and I would like to be able to use web deployment to deploy directly to Azure from Visual Studio. However, the guidance found here seems to suggest that if you want to do your own deployment, you need to use deploy.cmd. I'm not exactly sure why that is. I can only guess that it has something to do with how the modules need to be packaged up.
I am able to run deploy.cmd and it appears to succeed, but I end up with an artifacts folder with 2,000+ files and folders in it and I am left to use old-school FTP to sync all those files up with the Azure website. Is this how it is meant to be done? I have tried to deploy directly from Visual Studio to Azure, and it appears to succeed, but the site does not behave correctly. Specifically, the custom modules I've built don't load correctly.
What is the right way to do this?
There is a way to publish your custom module directly from Visual Studio, but you still need a working Virto Commerce in Azure beforehand, and the easiest way to set it up is to use the Deploy to Azure button in GitHub.
In the Azure portal create a new virtual application /MyModule with
physical path site\wwwroot\admin\Modules\MyModule. It will be used
for publishing a custom module.
Download the source code from GitHub with the same version as you have published to Azure, add your custom module to the solution and build it.
In Visual Studio right-click on your module project and select Publish.
On the Profile screen select Microsoft Azure Web Apps as a publish target and select your Azure Web App.
On the Connection screen select Web Deploy as a publish method and add /Module to the site name. So your site name should look like this: myvc/MyModule.
On the Preview screen click the Start Preview button and make sure the file list contains only files related to your module and the action is Add for each of them.
When you click the Publish button, Visual Studio will upload all module files to the physical directory configured for the virtual application myvc/MyModule. For subsequent publishing it will upload only modified files.
Update: You should restart the Web App via the Azure portal after publishing in order to load the new version of your code into the application. Thanks to N1njaB0b for reminding.

Set Up Continuous Integration From VSO to Azure, but Website does not deploy

I have an azure website that I have successfully linked to a team project in VSO. When I go to the "deployments" tab of this site in azure management, it says:
The team project is linked. Visual Studio Online will build and deploy
your project to Windows Azure on your next check-in.
Below, it gives options to check in from VS2012 or 2010. I am using VS 2013.
In VS, I am able to check in changes and see those changes building in the cloud in the team explorer. My expectation is that after the changes build, they should be auto deployed to the website. This is not happening. I have made several checkins, and none are deployed to the website. It's probably that I have something configured incorrectly, but I'm not sure how to debug this.
In the Build Settings I am using the TFvcContinuousDeploymentTemplate.12.xaml build process template. One thing I did notice is that the under the Deployment Parameters, I noticed that Windows Azure Deployment Environment is empty, but if I try to populate that I'm not sure what to enter for "Web site name" or "Webspace" under the web site radio buttom.
I have followed instructions on these websites to no avail:
http://azure.microsoft.com/en-us/documentation/articles/cloud-services-continuous-delivery-use-vso/
http://channel9.msdn.com/Events/Build/2014/3-584
http://www.visualstudio.com/en-us/get-started/deploy-to-azure-vs.aspx
How can I check on the status of the deployment? How can I make sure that the project/solution is correctly configured to deploy/publish and not just build?
Some additional info:
To set up the continuous deploy, I goto azure management portal, click websites, open the website in question. Click the Deployments tab. It says "The team project is linked, Visual studio online will build and deploy your project to Windows Azure on your next check in". Under YOUR SERVER is lists the correct visual studio online URL for my source project (https://------.visualstudio.com). This is my first time trying CD. It has not successfully deployed yet, but the build is working. Every time I check in changes, a cloud build is triggered and it is successful.
I'm new to this, so I am likely making some unfounded assumption, but after going through the instructions multiple times I'm not sure what I can be missing.
Thank you!
l19 has the right idea in the comment responding to my post. I needed to specify a Windows Azure Deployment Environment. The website name is the name of the website. Webspace is a bit trickier, and unfortunately the documentation link in visual studio redirects to a not found page. This has to be precise (e.g., "west us" won't work). I was able to figure out the proper string by creating a new project from azure and associating it with vso from the start. In this case, the build definition was correctly configured. I opened the Windows Azure Deployment Environment and saw that the webspace was set to "eastuswebspace", so I used the same string in my real build definition and it worked.

How do I debug my Azure web role in Visual Studio 2012?

I know this is probably something really stupid, but I've been searching google for 2 hours to figure this out.
I have a new test Azure app that I would like to debug in Visual Studio. If I set the startup project to the Web Role (MVC) project, I can hit breakpoints in VS, but it's not running in the emulator so all of my Azure calls fail.
If I set the startup project to the Cloud project, the emulator starts, then Visual Studio ends debugging and my web role is never launched.
What am I missing here? How do I launch my web page and still have access to the emulator?
(Side note.. why isn't there a Visual Studio 2012 tag??)
Although this doesn't answer your question directly, I always make sure that my projects run outside of the emulator. If for nothing else, this just greatly improves the efficiency of your development.
To avoid the issue of the Azure calls failing, one very basic practice you can use is to use a Dependency Injection framework (such as Unity or others) and create a LocalConfigurationManager and a AzureConfigurationManager which both implement some interface like IConfigurationManager, then if your code needs to ask Azure for an instance number, or config setting, etc... the LocalConfigurationManager can just return a hard coded number/setting, and the real AzureConfigurationManager will actually call Azure.
The trick is to use the Web.Debug.Config and Web.Prod.Config files (or perhaps just use the #IF DEBUG C# precompiler statement) to change the implementation depending on the build config.
I have just created a Azure project with an MVC Web Role and I was able to hit a breakpoint in a controller action without any issues. Some things to check:
Do you have a WebRole.cs file in your MVC project containing a class derived from RoleEntryPoint?
Is there a node in the Roles folder of the Azure project representing your MVC project?
When you run the Azure project does the Compute and Storage emulator icon show up in the Notification Area of the taskbar?
Does the ServiceDefinition.csdef file in your Azure project contain a Web Role node with an attribute matching your MVC project name?
WebRole name="MvcWebRole1" vmsize="Small"
As a quick test try creating a new Azure project with a MVC Web Role, add a controller with a single action that returns a view and put a breakpoint in there. Then set your Azure project as the "Startup Project". If everything is working correctly you should hit the breakpoint when you debug the Azure project.
I un-installed and re-installed all my Azure SDK's, to no avail.
This link
Debugging Azure: Error attaching the debugger to the IIS worker proccess
told me where to look for the error that was causing it to fail, which led me to this link:
http://social.msdn.microsoft.com/Forums/en-US/windowsazuredevelopment/thread/07fe087e-4ac3-4c4f-bd62-4fccff4afd45
The ACL on the Windows Azure registry entries were not in "canonical order".
All you have to do is fix that and this error goes away.
These are the steps I took:
1.) regedit, navigate to HKLM\Software\Microsoft\Windows\Windows Azure
2.) Right-click, choose "Permissions". You will get a warning that the
security information is incorrect and you get a button labelled "Re-Order".
Click this and the security information then shows up as normal.
3.) Follow the same steps for the Windows Azure AppFabric and Windows Azure Emulator
registry entries in the list after the Windows Azure entry.
Problem Solved!
Note that I found the key under HKLM\Software\Microsoft\Windows Azure, not under Windows\Windows Azure.

Web Application within a Web Site in Visual Studio?

Visual Studio allows you to make "Web Sites" and "Web Applications", but, inside a project, can you have one within the other?
Say I have my website "www.mysite.com" and I have an application called "BudgetCalculator". One the production server, this is supposed to be located at:
www.mysite.com/BudgetCalculator
And the BudgetCalculator app contains links back to other parts of the website, like "/page1" and "/page2".
However in Visual Studio, when they're listed as two different projects, they're on the same level. When I fire up the debugger for the BudgetCalculator app, those links aren't going to point back to the main website, like they should.
Is there a way around this?
One solution would be to stop using the built-in .NET Web Server.
Use IIS, create one site, and make your Web App a Virtual Directory inside of the Web Site.
A project cannot host/contain another project in Visual Studio.
You can however create a project that sites in the directory of another higher level project when you create it, however they may not be directly linked, so you couldn't debug them both at the same time.

Resources