After blogging for the last 10+ years here, I decided to move to MSDN blog for greater reach ability.
>>>> Please support me with your feedback & comments –http://blogs.msdn.com/b/maheshk/
Recently I worked for an office issue where Excel 2013 goes to frozen state after executing some time consuming VBA code/macro. It did some operations like – copy ranges and pasted over another sheet within the same workbook. The copy and paste operation iterates over some 100 thousand times depends on the data row etc. It took nearly 3-4 hours to complete the whole copy operation due to data density spreads to x columns with x number of rows.
Problem identification: We saw the application was very much alive but could not able to click or respond to our mouse events like maximize/minimize. Moreover it was slowing the system performance as well. We could not able to figure out the cause in the initial stage. But we tried tools like Procmon, windbg dumps, VMMAP etc could not give that heads up. But after checking the task manager GDI count, we come to know that this is sort of object leak – GDI Leaks creating this hang state/lock situation.
How to identify the GDI object leaks? It is so simple to check such leaks from the task manager itself. Launch the taskmanager > details tab > right click any of the existing column > then ‘Select Columns” enable GDI Object to get added to the details process grid. From there you can keep a note of the count to conclude whether its a GDI leak or not. Typically, you would find this count in hundreds, but in case if you notice them in thousands and also incremented, then something sure to do with GDI leak fix.
What is GDI Objects? According to this MSDN article – GDI Objects are resources that are managed by GDI32.DLL on behalf of an application. Some of the common GDI Objects we consume directly/indirectly through code – Device Contexts (DCs), Bitmaps, Brushes, Fonts, Metafiles, Pens, and Regions etc. These objects gets created using API call but when never gets destructed after usage – this would lead to this leak situation. As like in .NET, it is recommended to dispose of when not interested with that ready to cleaned objects. Of-course, we do this very judiciously, but at times when our code path not cleaned after some exception or some condition branching stops us to do so, then this would be a show stopper for sure :).
What is the limit? It is limited to 64,536 (64k) GDI handles per user session- across all process. But for any individual process, the upper limit is 10000. System allows us to create these many handles and then halts after reaching this limit. You could also try tweaking this limit from registry, but generally not advised to do so due to various reasons like -affects other application performance etc.
What happens after reaching this 10,000 limit? The application would be alive as I said earlier but of no use. It is starving to create further GDI Objects to render it but indefinite halt after that due to no more Create handles permitted. When an application goes out of resources, then the create API call to functions like CreateFont, CreateDC etc would fail with this error : ERROR_INVALID_HANDLE.
There are some tools and guidance to research more on this, but I see very limited materials around this in net. I suggest the below links.
Very old cached MSDN article(thanks to google cache) http://webcache.googleusercontent.com/search?q=cache:XOnUN-jJpGoJ:msdn.microsoft.com/magazine/efea0849-057a-42b7-a5bf-a106bd38faa2&hl=en&gl=in&strip=0&vwsrc=0
Debugging a GDI Resource Leak
Suggested to try these Office June updates in case of such leaks
https://support.microsoft.com/en-us/kb/2817579 (enhances copy paste operation speed)
https://support.microsoft.com/en-us/kb/3054794 (some fixes around object leaks)
In the recent build conference, we had few Azure announcements. Yes out of that, “Azure App Service” is something important for dev’s to learn and try out. Had a chance to go through this announcements, so thought of sharing the awesomeness in this post. Azure App service has got 4 features – Web, Mobile, Logic and API as below.
It actually enables us to to easily create Web(web sites) + Mobile + Logic + API Apps and also facilitate us to refer each of them without complex coding or integration pains.
- Azure Web Apps (aka Azure Websites – renamed)
- Azure Mobile Apps (aka Mobile Services)
- Azure Logic Apps (‘workflow’ style apps – get the data from one connector and pass it on to diff connectors)
- Azure API Apps (uses Swagger)
Azure Web Apps(a.k.a Azure Websites)
+ straightforward web hosting multitenant platform(PaaS), you can build and host websites using .NET, Java, Node.js, PHP, and Python. there is nothing new here, except renamed from Azure WebSites if you are familiar with.
Azure API Apps
+ new apps from MSFT, this is nothing but our HTTP based API projects. These API can be consumed by the application developed using .NET, Java, Node.js, PHP, and Python. It has got the metadata formatted by swagger (opensource frmk)
Azure Mobile Apps
+ SSO, + build engaging iOS, Android and Windows apps.
+ same like other apps – autoscale helps us to meet the sudden demand
+ you can easily integrate with facebook, Twitter, Google etc.
Azure Logic Apps.
+ again new from MSFT, it has the graphical dashboard workflow diagrams which helps us to experiment and implement easily without much of complex integration code. You could automate certain business process or workflow using designer. For out of the box, you may have to find one from market place. Key things include: Workflow, Connectors, Triggers, Actions
Videos explaining them – http://azure.microsoft.com/en-us/documentation/services/app-service/
Assume that we have got an exe(unmanaged/managed) which is crashing/hang/wanted to debug and see the intermediate values etc. For this example, I have used the below simple cpp program compiled to exe.
Steps for debugging this complied exe in Windbg:
1) Launch Windbg, -> Open Executable, browse and select our cpp program output “ConsoleApplication1.exe”
2) Now set the symbol path and source path pointing to its corresponding directory.
3) Reload the symbol to make sure the relevant symbols loaded.
4) If you press “g” mean go/F5 would run the program and displays the output.
5) Let us put some breakpoints at Main method and also Swap2Numbers to step in line by line debugging.
6) Since we have mapped the source code path also, now on typing “t” would execute/step in line by line. You would also notice the source code window opened up and breakpoint indicator set.
7) If you wanted to unassemble, then use> uf ConsoleApplication1!main (assembly code).
8) When you go line by line debugging, you can view the intermediate value of the function by typing >dv (display variable)
While I was going through the Exam: 70-532 preparation material, I hit these following pattern useful to the Availability, Resiliency and Scalability(ASR) of Azure WebSites and Azure Cloud Services. Wanted to table out here for later reference and detailed reading.
Useful for WebSites/WebJobs & WebRole/WorkerRole
■■ Static Content Hosting pattern
■■ Cache-Aside pattern
■■ Health Endpoint Monitoring pattern
■■ Compensating Transaction pattern
■■ Command and Query Responsibility Segregation pattern(CQRS)
Useful for WebJobs and WorkerRole
■■ Competing Consumers pattern
■■ Priority Queue pattern
■■ Queue-Based Load Leveling pattern
■■ Leader Election pattern
■■ Scheduler Agent Supervisor pattern
RESILIENT CLOUD ARCHITECTURES
> Microsoft Patterns & Practices at http://msdn.microsoft.com/en-us/library/dn568099.aspx [Download PDF]
> Designing resilient architectures for the cloud: http://msdn.microsoft.com/library/azure/jj853352.aspx [provides additinal insight, some specific to Cloud]
I just saw scott post on Azure Resource API lib intro. I thought let me think over all possible ways(recollect) today used to manage Azure Resources like VM, Websites, jobs etc from ones desktop.
1) https://portal.azure.com – famously called azure preview portal.
2) https://manage.windowsazure.com – old portal or manage azure portal.
3) Azure PowerShell – PowerShell is a friendly tool for infra guys/DevOps/Admin who manages and automate stuffs using PS commandlets, or advanced stuff like DSC -Desired State configuration, puppet,chef etc.
> There are lot of infra tools available in market place.
4) Azure Resource Manager API – over REST API – fire commands like PUT,GET,POST from your browser. You could also use ARM client here. It is really nice cmd utility with simple commands written by David E
5) Microsoft Azure Cross Platform Command Line (separate installer available for Mac and windows) – azure-xplat-cli
6) From your managed .NET code too – Microsoft Azure Management Libraries 2.0.0
> Scott H explained how one could do this coding here
7) Using Visual Studio Server Explorer – explained here.
P.s: Let me know if you have any comments regarding this and any other ways left out.
8) Blob Transfer Utility for Windows Azure Blob Storage – https://blobtransferutility.codeplex.com/ read via – http://geekswithblogs.net/tmurphy/archive/2015/05/28/azure-utilities-you-should-have-in-your-toolbox.aspx
When we swap deployment slots, all of the website content is swapped, but the not the configuration.
The following configuration items will move to the destination slot:
■■ General settings (for example, .NET framework version, Web Sockets, Always On)
■■ Connection strings
■■ Handler mappings
■■ Application and site diagnostics settings
■■ Monitoring settings
The following configuration items will not move to the destination slot:
■■ Publishing endpoints
■■ Custom domain names
■■ SSL certificates and bindings
■■ Scale settings
Note: this means that settings such as your db connectiong strings should be configured with the prod values before swapping.
Last week I have cleared my 70-487 Developing Microsoft Azure and Web Services certification. I have started preparing for 45+ days on and off, mostly weekend reading and able to clear through second shot offer. There are plenty of materials there to prepare, but I urge to stick with official curriculum + MVA (microsoft virtual academy videos) for this exam. I had internal employee measure up account with some sample questions, with deep understanding of all those concepts + small hands on helped me crack it. Here is what you will learn through this certification,
Chapter 2) Querying and Manipulating data by using EF – LINQ to Objects, entities, ADO.NET, EF, Lazy loading,data model…
Chapter 3) Designing and implementing WCF Services – SOA concepts, WCF API obj and config, Securing, consuming, version, Azure Service bus, one way-two way, hosting..
Chapter 4) Create and consume Web API based services – Design a web api, implement, secure, host and consume web api web services
Chapter 5): Deploying web application and Services- Design, deployment strategy, Configure, manage packages using Nuget, create, configure and publish a web package, share assemblies.
Overall, we will learn back-end programming/db programming + infra projecs like publishing, nuget, etc also helps us to uinderstand end -to end.
Study notes from Chris – http://www.bloggedbychris.com/2013/01/24/microsoft-exam-70-487-study-notes/
[Update: May first week – I have cleared 70-532 :) ]
DebugView is a developer friendly tool helps you to monitor debug output messages from local or nw system – from managed/unmanaged code. Recently I was debugging managed COM dll created in C# consumed in office application. I wanted a tool to debug end to end, Let say, your Office files VBA macro calls .NET COM dll for processing some complex logic and then returns the value to your macro.
In dev environment, we usually attach VS to the application and debug them, in VBA using debug.print statements. Assume that, you don’t have VS at your production server or customer machine where you wanted to debug them badly. Here is where debugview comes for rescue.
System.Diagnostics.Debug.WriteLine("This is from .NET before word instance.");
Private Declare Sub OutputDebugString Lib "kernel32" Alias "OutputDebugStringA" (ByVal lpOutputString As String)
Private Sub DebugPrint(dbgOutput As String)
DebugPrint ("Test message for the debugger")
Note: Make sue you run as “Admin”.
A Cloud and Azure Glossary for the Confused
Windows Azure Platform Glossary for IT Pros
Microsoft Patterns and practices – Azure Glossary
Pushing the Limits of Windows: Physical Memory
Pushing the Limits of Windows: Virtual Memory
Pushing the Limits of Windows: Paged and Nonpaged Pool
This weekend I had a chance to try this blog post by Kirk Evans here. Finally decided to try myself and experience the fact. Trust me, its one of the cool feature implemented in Azure. I can’t imagine how many lines of code would execute in the back-end for each of those button click from portal, say increase the core, queue, cpu etc – really hard to imagine or think about it.
#Hats off to Azure team for their flawless implementation. I was able to experience this feature end to end without any bug or hassle. few observation from my point,
How to automatically scale the worker role based on the number of messages in a queue
+ Kirk has used Azure service bus to validate this functionality. I have also used the same .NET console application to pump the queue message. It took sometime to fix those project reference etc. Finally with Nuget able to resolve the dependencies and publish it successfully.
+ Everything went flawlessly from there. Spent my time mostly in the portal to know the settings and tweaking it. I think we should bring those nuget console to the project context menu for quicker launch. Right now it is buried some where under main menu of Visual Studio.
+ Though auto scaling worked like charm, the dashboard chart is not getting refreshed or reflecting real data, not sure what’s going on there.
Note: Auto scale feature automatically creates or destroys the VM’s based on the rules
+ Screenshots here.
Happy weekend !
I’ve just come across the below Pizza as a Service chart from linkedin. I just added our Azure chart as well below for side by side comparison. I should give full credit to “Albert Barron” who created this pizza chart and article here. Very layman explanation for Cloud service.. Fantastic.
This weekend, I had a chance to explore Azure RemoteApp. In nutshell, this App runs on Windows 2012 R2 over rdp service. We usually RDP to a remote machine but in this case, we are rdp’ing to a particular published apps without any visible difference like window border or floating bar etc. Trust me, end user won’t be able to identify whether they are on a remote app or local app. I am really impressed with the design thought.
We can connect to a remotely published apps from a azure portal and then use it by installaing a small exe at client machine for logon and app selection. As of now, It comes with few default Office applications(apps) but in case of hybrid option you can customize by uploading your VHD’s as per our wish.
Since this supports resume and continue kind of state management, you could logoff from your office and then continue from home using any device from the place where you’ve left.
+ It delivers the functionality of the on-premises Microsoft RemoteApp, backed by Remote Desktop Services
+ Helps you provide secure, remote access to applications from many different user devices. Available for Windows 8.1, Windows 8, Windows 7 Service Pack 1, iOS, Mac OS X, Windows RT, Android, devices, and Windows Phone. It also support the Windows 10 preview.
> To achieve this, you need to install a clickonce installable RemoteAppClient from here – https://www.remoteapp.windowsazure.com/ClientDownload/Windows.aspx
> Azure documentation: http://azure.microsoft.com/en-us/documentation/services/remoteapp/
> Azure RemoteApp Cloud Deployment overview
> Understanding Azure Remote App
Microsoft Azure infographics
Microsoft Architecture Blueprints
Top architecture trends and perspectives
Cloud application development
I got this tools link while searching for Azure Storage free tools – explorer. Azure Storage Explorer is simply a nice tool to work and explore. It is free, elegant and clutter free to use. It just fulfill our expectation. #Good job by david
Download it from here – http://azurestorageexplorer.codeplex.com/