Tuesday, April 30, 2019

Architecture of www.JoymonOnline.in via PlantUML

The previous post was about setting up the environment for coded C4 architecture diagram using PlantUML. This post is about how the same can be leveraged for the architecture of www.JoymonOnline.in web site.

It is just a simple personal portfolio site whose architecture has already done in C4 model. The conversion is simple and its available along with the source itself in GitHub.

Below is a screenshot how it render in VS Code.

Its difficult to unless opened in a different window.

Happy diagramming...

Tuesday, April 23, 2019

Setting up PlantUML for coding C4 architecture diagrams

Background

Earlier there was a post in this blog related to documenting architecture using C4 Architecture model. The architecture of www.joymononline.in is documented in the C4 way. At least, the context diagram. The problem what was tried to solve in that post was how to make code inline with architecture.

It is easy to document architecture for a static portfolio site or a simple CRUD operations site with a login feature. But difficult in Enterprise systems especially, if the rate of change is so rapidly. Nowadays the software is changing its happening at high speed with the advent of DevOps culture and practices such as continuous integration, delivery, monitoring, etc...

Problem

When we follow any documentation model as a technical person, we may face below problems
  • Versioning with application code.
    • What if a feature branch changes the architecture or component interaction or alters dependencies
    • Comparing what changed from the last version?
  • The time-taken to beautify the diagrams. Skills depend on person to person and difficult to get it uniform when the organization grows.

Potential solution

One way we could apply is coding the architecture. Meaning, store the architecture diagrams in textual representation and store along with code. Generate diagrams out of it. It is a simple idea similar to using markdown for documents. It's human and machine-readable.

Let's see one way to document the C4 architecture model using textual language. First introducing of some terms and later see how they are smartly glued to get coded C4 architecture diagrams.

PlantUML

This is a text-based UML modeling. This has specs and free to use. It has also Java-based rendering mechanism which uses another free software called GraphViz to visualize the diagrams.

GraphViz

This is a visualization tool for creating diagrams. Its open-source. This is needed by PlantUML to render charts.

VS Code & PlantUML extension

This is the developer's favorite editor. As usual, there is an extension to easily write and preview the diagrams. The name of the extension is 'plantuml'. We can either install via extension editor or by command. Thanks to the author Jebbs for the extension and making open source.

How to setup VS Code for PlantUML is already mentioned in the below link. Since we are living in the 21st century, the Japanese language in the post can be converted automatically by the browser to English:)

C4-PlantUML GitHub repo

The magic is here. Below repo has the C4 customization files for PlantUML to understand the C4 language.

Big thanks to Ricardo for his work and especially for open-sourcing the same. The repo has enough details about the capabilities and sample to get started.

Another interesting thing he did is the availability of Azure customization. These files help us to create diagrams using Azure symbols than boring boxes.

Troubleshooting

Though some of us get the environment working in the first attempt itself, I am trying to do a video (my first tech video) on how to set up the environment for doing C4 architecture of www.joymononline.in via PlantUML notations and the tools mentioned above

If we go step by step there will not be any issues. Below are the steps
  1. First, install Java. That will make sure the PATH variable is set properly.
  2. Then install GraphViz. Even there is no issue installing in a different order as those are not dependent. 
  3. Now install the VSCode and 'plantuml' plugin. the plugin contains the plantuml.jar file. 
  4. Finally, download the customization from C4-PlantUML repo and open in VS Code. 
  5. Check the preview by Alt+D shortcut.

Once we have the environment setup its easy as typing the diagram and previewing it in the same window. Commit the file once ready. Better integrate with the build pipeline.

Conclusion

The mix of specs & tools is little complex but easy to set up and use. Though there is no support for the tools we as developers can fix the issues and add features in those tools and give back to the community

Tuesday, April 16, 2019

ASP.Net Diagnostic page to dump request and environment for troubleshooting

It is often seen that we need to dump all the request variables such as headers and all to do troubleshooting. Many things can be dumped using IIS logs itself either by enabling those or by adding extended data fields. Refer below link for details on extended logging.
https://docs.microsoft.com/en-us/iis/extensions/advanced-logging-module/advanced-logging-for-iis-custom-logging

But in some scenarios that is not enough. For example to ensure that the user name / alias is correctly obtained in ASP.Net code. In those scenarios, it is better to dump using custom code. Below is a code snippet which uses ASP.Net template techniques to dump http request and environment variables such as user name etc...

It doesn't need any code behind or pre-compilation. Just save this as file with .aspx extension say dump.aspx.


Running the dump.aspx

Place into the folder and browse that file as
http://<FQDN>/<app name if applicable>/dump.aspx

eg: https://localhost/MyApp/dump.aspx

It is advised just put this file when we debug and not to add as part of application. But if permitted  check in this file into source control so that the troubleshooting will be much easier.

This is tested mainly in .Net Full Framework. Yet to check with .Net Core.

References

The problem has already been faced by many and there are already enough links where people shared the solution. Since every solution is unique putting one more along with some below.

https://code.msdn.microsoft.com/ASPNET-Diagnostic-page-to-9a029c20
https://pedrosneglectedtechblog.blogspot.com/2010/02/quick-and-easy-http-header-dump-aspnet.html
https://blogs.msdn.microsoft.com/friis/2013/01/08/asp-net-authentication-test-page/

Tuesday, April 9, 2019

Visual Studio Online / Azure DevOps load testing - On-premise agent service is not starting

This is a simple troubleshooting post related to VisualStudio Online or Azure DevOps load testing.
The load testing needs agent programs to be installed on multiple machines to generate load. We can use agents provided by Microsoft as well if our application is straight forward and accessible from Microsoft hosted agents.

If we are in Enterprise or in restricted environments, we may have application hosted internally and only accessible via domain joined machines or via other constraints. Then we need to run the agent program on premise.

Problem

The agent program is a windows services which we can see in services.msc console. Sometimes the agent service gets stopped and below error will show up when we try to restart.

---------------------------
Services
---------------------------
The VSTSLoadAgentService service on Local Computer started and then stopped. Some services stop automatically if they are not in use by other services or programs.
---------------------------
OK 
---------------------------

Solution

Since this Azure DevOps load testing tool is deprecated now and ending its life next year around this time, lets not go into the details why its not working. Lets see a hack.

As standard Microsoft solution which is as famous as machine restart, lets uninstall and install the agent program again and it will work.

Since the installation is by running below PowerShell scripts, it doesn't seems polluting registry and all.

Uninstalling agent

Uninstall command needs the agent name. If the name if unknown, first we need to get agents list. Example is as follows.

.ManageVSTSCloudLoadAgent.ps1 -TeamServicesAccountName https://<organization>.visualstudio.com -PATToken <PATToken> -AgentGroupName <group name> -GetAgents

to uninstall an agent follow the below command.

.ManageVSTSCloudLoadAgent.ps1 -TeamServicesAccountName https://<organization>.visualstudio.com -PATToken <PATToken> -DeleteAgent -AgentGroupName <group name> -AgentName <agent name>

Now install the agent again.

.ManageVSTSCloudLoadAgent.ps1 -TeamServicesAccountName https://<organization>.visualstudio.com -PATToken <PATToken> -ConfigureAgent -AgentGroupName <group name>

The ManageVSTSCloudLoadAgent.ps1 file can be downloaded from this location. The commands above has some parameters enclosed in '<' & '>' as placeholders. We need to use actual values there.