Skip to main content

Posts

Showing posts from August, 2016

Azure Service Fabric: Exposing endpoints to the outside world

The first time I created an Azure Service Fabric cluster, there was one very importing thing I forgot to configure; custom endpoints. Custom endpoints allow you to expose a stateless or statefull service to the outside world. Without this the service is only accessible from inside the datacenter. The annoying thing is that you can only set the custom endpoints when you create your cluster. I couldn’t find a way to change this after the cluster is created. This means that if you forget to add a port, you have to recreate your cluster from scratch. My current solution is to preconfigure a range of ports so I don’t run out of available endpoints while developing. To use one of the available endpoints, you have to configure the port you want to use in the ServiceManifest.xml: <?xml version="1.0" encoding="utf-8"?> <ServiceManifest Name="SampleService"                  Version="1.0.0"                  xmlns=&qu

Akka.NET Tip: Name your actors

A small tip when you start using Akka.NET; name your actors. By default when you create an actorref Akka.NET will assign a name for you. var actor=system.ActorOf(Props.Create<SampleActor>()); The problem is that when you add some logging, you’ll get errors like: An error in occured in actor akka://test/user/$a/$a/$b which is not very useful if you want to investigate what’s going wrong. Remark: This is an error from inside a unit test explaining the “akka://test”. Instead using an ActorOf overload that allows you to specify a name: var actor=system.ActorOf(Props.Create<SampleActor>(),"sample-actor"); That’s it for today!

Help! IIS logs are filling up my disks

This morning I got a warning on one of our dev servers that the disks were almost full. Whoops! Time to take some action before our dev environment goes down… After running some diagnostics on the server we found out that most of the disk usage was caused by the IIS logs. After removing some older log files, we already felt a little better. But how can we prevent this from happening again in the future? I could add a recurring task in my agenda and check the server every month. But there have to be some better alternatives. And no, just disabling the log files is not an option. First thing we did is enabling folder compression. The IIS logs are simple TXT files which compress very well. Just by doing that we were able to shrink the files to about 2%(!) of their original size. Here are the steps: Open File Explorer . Browse to the folder containing IIS log files (by default, %SystemDrive%\inetpub\logs\LogFiles). Right-click on the folder and click Properties . O

AADSTS50001: The application named was not found in the tenant named .

Today we lost some investigating why we couldn’t authenticate a WinForms app using ADAL to Azure AD. Here is the code we were using: And here is the exception we got: AADSTS50001: The application named .onmicrosoft.com/sample">https://<resource>.onmicrosoft.com/sample was not found in the tenant named <tenant>.onmicrosoft.com.  This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant.  You might have sent your authentication request to the wrong tenant. Trace ID: a1b52908-f2c8-4f9d-aabb-e0050ff9ca0c Correlation ID: 9f0ec9de-2f32-47b2-9d25-11333b2bd1d6 Timestamp: 2016-08-26 10:22:17Z If you see the error above, triple check your configuration values. Almost all the time this means you have a typo somewhere causing Azure not to find the correct information. In our situation we had a typo in the APP ID URI…

ASP.NET Web API: Remove XML formatter

ASP.NET Web API supports the concept of media formatters. Based on the content-type you set in your request headers different output can be generated. Default formatters exist for XML and JSON. However I had a situation where I only wanted to return JSON output. Removing the XML formatter can easily be done through the Web API configuration inside your startup.cs file:

Web.config transformations: How to update an appsetting value

Web projects in Visual studio support the concept of web.config transformations, making it easy to update your configuration depending on the build you are using. Yesterday I had a hard time to remember what the exact syntax was to update a specific appsetting. So here is a small snippet to help me remember:

TFS–User \ needs the 'ManageBuildResources' permission to add, update, or delete the build resources on the server.

When trying to install and configure a XAML Build controller I got the following error during the validation step: User <domain>\<username> needs the 'ManageBuildResources' permission to add, update, or delete the build resources on the server. Ok, no problem. I know that to configure the XAML Build and link it to a specific collection you need to be part of the Project Collection Administrators or Project Collection Build Administrators group. So I opened up the TFS Administration Console, browsed to the Collection where I want to add a build controller and clicked on Group Membership . The Global Groups window is loaded and here I can add the user(Click on Properties … –> Add ). Unfortunately this didn’t solve the problem. Although I had added the user to the correct groups, the error keeps appearing… However when I added the user to the same groups through the web portal, it did work. Strange! Open the Web Portal Go the Administration site Select t

Team Foundation Server Administration Console: Index is out of bounds.

Got an email this morning from a customer asking me if I had seen the following error message before when opening the XAML Build Configuration inside the  TFS Administration Console: “Index 10985 is out of bounds.” This is an error I had never seen before. The thing is that the system itself was working as expected. I asked to take a look at the logs. There we noticed that an enormous amount of event messages were generated. Could this be causing the issue? And indeed after we cleared the event log, the XAML Build configuration appeared again. On the screen some Events related data is shown, probably this couldn’t handle the large load of messages…

Telerik WPF controls: XAML vs NoXAML

On a WPF project we are using the WPF controls from Telerik. Inside the Telerik folder we noticed that their are actually 2 versions of the binaries available; a ‘normal’ and a NoXaml version. So what’s the difference and which one should I choose? The normal assemblies contain some components together with a default set of styles and ControlTemplates. As most assemblies contain multiple components this can start to add up, as styles and templates for every component are provided. This also means that some of these assemblies are big. To decrease the file size, a NoXaml version of the assemblies was created including only the components themselves but no xaml code(styles, brushes, controltemplates,…). However as the NoXaml version doesn’t contain any visualization information, using these alone will not make much sense. No visual output will be rendered on the screen. A NoXaml dll should therefore always be combined with a theme dll. So which one should you pick? If you are onl

Akka.NET TestKit–No tests found to run.

I’m currently working on a project where I’m using Akka.NET and the Actor model. I’m amazed by the ease-of-use and how the actor model itself makes complex problems easy to implement. Anyway, I lost some time today investigating a problem that a colleague had. After installing TestKit and writing his first actor based unit test, the Test Runner explorer refused to work and the only output we got was: No tests found to run. After a few minutes I realized our mistake, we downloaded the Akka.TestKit.NUnit which is suitable for NUnit 2 and older. However we are using NUnit3, which requires a different NuGet package; Akka.TestKit.NUnit3 .  After installing the correct NuGet package, our tests appeared and the problem was gone. Kind of stupid to stumble over this problem because I had the same issue before (and even mentioned it explicitly in a previous blog post about Akka.NET; http://bartwullems.blogspot.be/2016/07/testing-your-akkanet-actors-using.html )

Angular 1.5 Components: Pass event data to components

I got some trouble finding out how to pass event data from a child component to a parent component. Here is a quick example to explain the problem: - Imagine I have a ProductListingComponent. Inside this ProductListingComponent, I have a ProductListComponent that renders a list of ProductListItemComponents. On every ProductListItemComponent I have a “Add to Basket” button. When I click on this button I want to add the selected product to my shopping basket that is managed at the ProductListingComponent level. How can I easily pass the selected product up to my parent components? Let’s find out. Let’s first create the 3 components with their html: Now I want to add a function to handle the click on the “Add to Basket” button and pass the product to the parent component. The correct way to pass data between child and parent component is through events. So let’s first add an ng-click directive to the button and extend our components to output an event: Last step and that i

.NET 4.6.2–The Long Path edition

While cleaning up my RSS feeds, I noticed a new update of .NET; .NET 4.6.2. Normally I wouldn’t care so much for a minor release but this one caught my attention. Why? Because the following fix was mentioned; Fix the 269 character file name length limitation . This  has annoyed me for a long time, and I’m happy to see that they finally fixed it. For most of my applications it didn’t matter but I had some file copy tools that got into trouble when folders were nested too deeply. This new capability is enabled for applications that target the .NET Framework 4.6.2 (or later). From the announcement : The following improvements were made to enable long paths: Allow paths that are greater than 260 character (MAX_PATH) . Paths that are longer than MAX_PATH are allowed by the BCL. The BCL APIs rely on the underlying Win32 file APIs for limitation checks. Enable extended path syntax and file namespaces ( \\?\ , \\.\ ) . Windows exposes multiple file namespaces that enable alt

Activate Application Insights on IIS using Powershell

There are 2 ways to start using Application Insights in your applications: Option 1: You install and add the Application Insights SDK to your application. This is easy thanks to the Visual Studio integration but requires you to open, configure and release each application separately Option 2: Use the Application Insights Status Monitor tool . This tool allows you to instrument a live web app with Visual Studio Application Insights, without having to modify or redeploy your code. Remark: Note there is a third option through the Application Insights extension but this only applies to applications hosted on Azure. After installing the Application Insights Status Monitor tool, you can pick the installed web applications that you want to monitor. Of course, ‘real’ administrators don’t use a UI but choose Powershell instead . Application Insights supports this through the Microsoft.Diagnostics.Agent.StatusMonitor.PowerShell.dll module. Here is an example how to use it:

Visual Studio: Improve your build output with the BuildVision extension

This week I started a new Azure project together with 2 colleagues. While debugging an issue with Azure Service Fabric, I noticed that his build output looked completely different. He was using the BuildVision Visual Studio extension . From the website: BuildVision activates when Visual Studio starts the process of building, rebuilding or cleaning projects (solution). BuildVision tool window and Visual Studio Status Bar displays the current state of the process, for example: "Build solution 'MyApplication' started at 18:24:12 ..." or "Clean project 'MyProject' completed successfully at 18:25:20". During the process, for each project the following columns are updated: State, Build Start Time, Build End Time, Elapsed Time, etc., as well as Errors, Warnings and Messages produced by MSBuild. Indicators Panel, which is located above the table of projects, displays total number of errors, warnings and messages produced by MSBuild, the nu

Enterprise Library Logging Application Block: Create a Logger instance

Last week I had to open an old codebase and fix some bugs(and some failing tests along the way). The project was using the Enterprise Library Logging Application Block. Inside the test project I got some trouble to get the Logger object working. It took me some time to figure out that you need to configure the Logger instance first:

Visual Studio Performance Tools: Instrumenting signed assemblies

Inside Visual Studio if you try to instrument a signed assembly you”ll end up with an error and the performance profile session will fail. AssemblyToProfile.dll is signed and instrumenting it will invalidate its signature. If you proceed without a post-instrument event to re-sign the binary it may not load correctly. The problem is that instrumentiation will inject extra instrumentation probes into your code requiring the assembly to be resigned. (The whole idea of assembly signing is to guarantee that there is not tampered with your assemblies). To solve it I used a small hack. Add the following key to your registry: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\StrongName\Verification\*,* WARNING: This will disable strong name verification for all your signed assemblies. So remove this key after you’re done profiling.

The path of an architect

A question I get a lot is “How to become a software architect” ? Most of the time I start answering by asking what they think the role of an architect is in a software project. And based on that answer we’ll start to discuss… If you want the opinion of Juval Lowy, software legend and master architect, go watch this video on Channel 9. And if you want to know my ideas, buy me a beer and I’m happy to share my thoughts…

Comparing Cloud platforms

Today, I got 2 great resources to share: First one is the Demystifying the Microsoft Azure platform post by Kunal Chandratre where he walks through almost all components inside Microsoft Azure and mentions the equivalent component in Amazon AWS. Image from dotnetcurry.com : Second one is the AWS vs Azure vs Google Cloud Platform comparison provided by Endjin. A full breakdown and comparison of cloud providers and their services are available in this handy poster .

Upgrading Angular 2 from beta 17 to RC4–Lessons learned Part 2

This is a continuation of a previous blog post found here: http://bartwullems.blogspot.be/2016/08/upgrading-angular-2-from-beta-17-to.html New router We’re almost there. With the upgrade from beta to RC the Angular team throw away their first Angular 2 router implementation and build a new one. Let’s fix our code to use the updated router… In my original code I had the following: I updated it to the following: Next, I extracted the router config to a seperate file and created a provider to load it inside the Angular bootstrap logic: The code to get router data changes as well: The information from the current route is accessible through the ActivatedRoute object. This is an observable and inside your component you can subscribe for changes. However in this sample I used the snapshot property which captures only the state on the moment we navigated to the component(which is sufficient for this example). More information about the “new new” router can be found in the

Upgrading Angular 2 from beta 17 to RC4–Lessons learned Part 1

Last week I had to make a change to an existing Angular 2 codebase(written using Angular 2 Beta 17). Before applying the change I decided to (quickly) update the code to Angular 2 RC4. Turns out that quickly wasn’t so quick after all… A lot of things have changed between the beta and RC. Here are some of the lessons I learned along the way: NPM packages The NPM packages have been renamed and do no longer contain Angular2 in their name. Instead they switched to @angular . Here is my updated package.json: Of course I had to update the imports inside my components as well: import {Component} from "@angular/core"; import {ROUTER_DIRECTIVES} from '@angular/router' import {HTTP_PROVIDERS}    from '@angular/http'; System.config changes After updating my NPM references, I got another error: Error: SyntaxError: Unexpected token <(…) Angular was no longer able to load my scripts. When I took a look at the network tab in

Writing Angular 1.5 components in TypeScript

I like the addition of components to Angular 1.5. Not only are they simpler  compared to directives, they also are the way forward to Angular 2. Yesterday I was investigating with a  colleague why a specific component didn’t work. Turned out that it was a (stupid) typo in our TypeScript code. We first thought we had a mistake in the way we constructed the component using TypeScript. So we unnecessary lost time questioning if our TypeScript implementation was causing the issue. Therefore I add a quick code snippet  here as a reference for future usage:

Azure Service Fabric Actor Design Patterns

Interested in using Azure Service Fabric, Microsofts Micro Services platform? But you have no clue what the actor concepts brings to the table? A great help form me was the design patterns paper by Jesse Benson. He starts with an introduction and then continues with a range of possible patterns: Pattern: Smart Cache Pattern: Distributed Networks and Graphs Pattern: Resource Governance Pattern: Stateful Service Composition Pattern: Internet of Things Pattern: Distributed Computation He ends the paper with some Anti-patterns . I also would recommend the Reactive Messaging Patterns with the Actor Model book by Vaughn Vernon. Although it is written for Akka , the patterns are applicable to Service Fabric actors as well.