How to speedup debugging on Azure Service Fabric? - azure

Debugging an ASP.NET MVC application on the Azure Service Fabric platform takes a long time. How do I speed it up?

If you are talking about cloud cluster debugging then that is going to be a bit slow process if you are attaching debugger to that cluster, in which case you should be relying more on your application logs to find a problem because you should try to replicate the problem in your local cluster first and debugging that locally will be much easier.
Now if you are trying to debug on local cluster then couple of things are important to speed up things.
Set your cluster to run in 1 node configuration rather than 5 node
configuration.
Set your "Application Debug Mode" to "Refresh Application". To do
this, right click on the fabric project in your solution and click
on properties. you will see a window where you can set project
properties, here you will see this option of setting "Application
Debug Mode".
once you have done this then you can hit F5 and the debugging will be a lot faster. Also remember that you don't need to publish your application every time you make code changes, all you need is build and cluster will pick up changes and you can debug any time. one last thing to remember is that if you make any changes to your settings.xml or manifest.xml files you will need to publish in order for these settings to be picked up by the application.
Hope that helps.

Related

Set up Azure Application Insights for local environment

We have set up Application Insights for our Dev & Prod environments, not with the SDK but through the Portal. We're now in the process of installing the SDK so we can have more control over customizing logging, what to measure in performance, etc.
I have found how to separate the environments in code (separate Instrumentation Key in different config files etc), but I have found nothing when it comes to my local environment. Which instrumentation key should I use there, the dev one? Wouldn't then this skew our dev metrics everytime one of the developers runs the app locally?
And also, doesn't it make sense to have a separate App Service slot just for the local environment, so I can test everything and see the logs I'm trying out locally, and not have to deploy to dev everytime I want to see what I'm doing?
I've tried creating a separate slot for local, but it generates a weird url based on the name I give, which I can't change later.
I've googled for a couple of days already and couldn't find any (or very little) helpful advice when it comes to this.
I realise there is a "Just add the SDK to try local only mode" option in Visual Studio, but then I would have to use it exclusively locally. What I want is to use all three - my local, dev & prod.
We're using .net core 2.2 for our backend and Angular 7 for front end.
I'm an idiot.
The url set up automatically basically means nothing. I solved the problem by just adding another App Service slot (created from our App Service production one, just like dev), and added this key to the local settings in our project.
Now we can use this key to get real time results as we debug, and use the other two for dev & production.

How to properly use Application Insights in UWP, offline scenario

In my UWP app I want to use Application Insights, but after many hours search for the best implementation, I don't know how to do it.
I use MVVM Light, and in App.xaml.cs added below code:
WindowsAppInitializer.InitializeAsync();
In the every ViewModel I have new instance of TelemetryClient. Everything looks great, but I have a problem with synchronization in offline scenario.
I assume that in this situation data should be stored in AppData\Local\Microsoft\ApplicationInsights{appGuid} or AppData\Local\Packages{appGuid}\LocalState\ApplicationInsights and then sync with Azure, but both localization are still empty. The same problem exist when I'm offline in release and debug mode.
What is your suggestion for me ?
In you ViewModels, do you use the instance of TelemetryClient to send some data to the server (or to the cache, in offline mode) ?
Also, have you properly configured AppInsights ? Does it works when you are online ?
Edit: Does is happened in Release Mode or Debug Mode ? According to the doc:
https://azure.microsoft.com/en-us/documentation/articles/app-insights-windows-usage/
Debug
If you build in debug mode, events are sent as soon as they are
generated. If you lose internet connectivity and then exit the app
before regaining connectivity, offline telemetry is discarded.

Remote Debugging Azure Mobile Service

Trying to debug azure mobile service running in the cloud. I have published debug configuration, in the options indicated to allow debugging non JustMyCode and use source server.
Attach to running process works and I could put break points and step through the code, though I could not get the values of any variables. Even 'this' would not show the values in the watch window.
Prior to that I was trying to debug a release published configuration and the watch used to display values of some of the variables. Others were indicated that due to optimizations values are not available.
Thanks for help,
Ruben
I think you did something wrong, because if you did the remote debug the break point should be hit and you can see all data.
Please see this article
Cconnecting a menu app to azure mobile service > How to do the remote debugging
If it not help, provide a movie with that you are doing :)
I recommend to have Azure SDK 2.5 and Visual Studio 2013 update 4

How do I debug a Worker Role using Remote Desktop with Windows Azure?

I now have my Windows Azure environment set up so that I can access my Worker Role with Remote Desktop. However, I'm not sure how to proceed at the moment. After much digging I found a web site that was offline but in Google's cache there was mention of attaching to the Worker Role running in the Azure Cloud from the Visual Studio debugger. But I only have Visual Developer (not studio) 2010 and I have searched all over and as far as I can see there is no such option to attach to a remote server. I am able to publish my project to the Azure Cloud without error and I have a "healthy" instance of my Worker Role showing as active and running.
I did connect with RDP through the Azure Management portal. The login worked fine and up came the remote desktop window. I searched through much of what I could find and was unable to find my Worker Role. I must have the wrong impression of RDP, because I had hoped to see the Worker Role's main display form when I logged in, just like I do when I debug it locally in the Cloud Emulator. But instead all I saw was a blank desktop with some base level server inspection and management routines. I even checked the Event Viewer for Application related messages and saw none.
So now I'm stuck wondering if my Worker Role is actually running or not, despite the seemingly positive status messages from the Management Portal, and I still want to attach to my Worker Role for debugging through Visual Developer, if it's possible, but I am unable to figure out how.
Anyone with experience in this area that can give me some solid tips on what to do next, please respond.
UPDATE: I believe my worker role may be running because I opened a command window and did a Netstat and saw it listening on the correct port. However, that may just be my Worker Role shell class that starts the custom EXE I have it launch as a spawned proces. I still haven't confirmed if my custom EXE is running yet.
UPDATE-2: Just ran TaskList from a command window and the custom EXE is listed.
UPDATE-3: Everything is working as I just ran a remote test of the service so that's not a problem. Still want to know how to attach to the Worker Role from Visual Developer 2010 for remote debugging, and if it's possible to see the custom EXE's display form like I do when doing local debugging in the Cloud Emulator.
-- roschler
There is a set of articles here which goes in length on how to set up for remote debugging in Azure:
http://blogs.u2u.be/peter/post/2011/06/21/Remote-debugging-an-Azure-Worker-role-using-Azure-Connect-Remote-desktop-and-the-remote-debugger.aspx
http://blogs.u2u.be/peter/post/2011/06/24/Remote-debugging-an-Azure-worker-role-using-Azure-Connect-remote-desktop-and-remote-debugger-part-2.aspx
http://blogs.u2u.be/peter/post/2011/06/26/Remote-debugging-a-Windows-Azure-Worker-Role-using-Azure-Connect-Remote-desktop-and-the-remote-debugger-part-3.aspx
The key takeaway is that you don't need to actually install Visual Studio on Azure, you only need to copy the Remote Debugger bits and then use Azure Connect to add your developer machine to the Virtual Network.
You can setup Remote Debugging with Visual Studio 2012
http://code.msdn.microsoft.com/Remote-Debugging-Windows-dedaaec9
When you say:
But instead all I saw was a blank desktop with some base level server inspection and management routines.
this is exactly what you get with an Azure VM. It's a basic OS install, plus the bare minimum of Azure stuff it needs to run and the code you've uploaded. There's no fancy monitoring or health checks available on the machine by default, you're expected to have provided those yourself to have them available without having to RDP into the machine to check on it.
RDP is very good for tracking down certain problems, like checking that a startup task will run, checking which directories items are installed in and just generally being nosey. If you need extra tools to track down a problem, you can just install them while you're connected to the server. For example I have RDPed into a server and installed the Microsoft Debugging Tools, to track down a memory issue.
I suppose you could remote into your VM, install Visual Studio there, and debug the process...
I also suppose it might be possible to enable remote debugging (not sure what's involved there, but such a thing exists, and it works over TCP) and debug from a local instance of Visual Studio.
To my knowledge, neither is commonly done.
Based on other answers, you would be better off writing a log file to a local storage. You can read the file from RDP if you reallyhace to. Keep in mind, debugging on Azure isn't really simple, and rightly so.
What I was thinking though was, maybe you could run the process using the user's credentials. I can't verify at the moment, but you have a better shot of seeing the ui when you rdp.

why two explorer windows are opened from visual studio in Azure project when I press F5

When I Press F5 to run the Azure project containing two worker roles and a web role. It opens two windows with same URL and they take so much time to open as well.
By time consuming, I mean, the website is taking too much time to load, but no such functionality or code is to be executed in the controller.
Can any body guide me on this?
It takes more time to start Azure project simply because it does more stuff. Just for starters, every time you press F5, it creates and configures new application pool for each role, then it creates and configures new web sites for each role instance.
I found it sometimes much faster to start the sites by pressing Ctrl+F5 (i.e. start without debugging). Then you can attach to your process manually, but you are free to do modifications to many files without re-deploying roles. This is especially helpful if you modify something that does not require rebuilding your binaries.
For your other question, you can control how browsers are launched for HTTP and HTTPS endpoints by using Configuration tab of the role properties. Just uncheck endpoints you don't want your browser to be launched on.
Try using the last Azure SDK edition v1.4. With the previous versions of the SDK there were some performance problems when running a service locally. Regarding the two opened windows problem, this might happen because the compute and the storage emulator were started manually on the local machine and not by the Visual Studio. At least in my case this was the problem. After shutting down the app., the compute and the storage emulator and running again the app.(F5) everything should be fine.
I've seen this happen before as well.
However, there is a way around it. You can edit the ServiceConfiguration.cscfg for your web role and set the instance count to 0. Then set your actual web application as the startup project instead of the Azure Web Role. This will allow you to use Cassini / IIS Express instead of the Compute Emulator to develop your web application.
NOTE: When you do a deployment you will have to set the instance count to something greater than one.
<ServiceConfiguration serviceName="Web" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="2" osVersion="*">
<Role name="WebRole1">
<Instances count="0" />
<ConfigurationSettings>
<Setting name="LogLevel" value="Error" />
</ConfigurationSettings>
</Role>
</ServiceConfiguration>
ALSO NOTE: There are certain features you will not be able to test when running your site like this. One example is local storage. If you're using features like that in your application you can simply switch the configuration and startup project back.
You'll also notice a huge speed increase when you press F5 to debug your application.
I've seen this happen with Chrome and Firefox. It doesn't happen with IE. Sorry I can't explain "why."

Resources