Wednesday, August 31, 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"
    <!-- This is the name of your ServiceType.
         This name must match the string used in RegisterServiceType call in Program.cs. -->
    <StatelessServiceType ServiceTypeName="SampleComponentType" />

<!—Some content removed—>

      <!-- This endpoint is used by the communication listener to obtain the port on which to
           listen. Please note that if your service is partitioned, this port is shared with
           replicas of different partitions that are placed in your code. -->
      <Endpoint Protocol="http" Name="ServiceEndpoint" Type="Input" Port="9003" />

Tuesday, August 30, 2016

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!

Monday, August 29, 2016

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:

  1. Open File Explorer.
  2. Browse to the folder containing IIS log files (by default, %SystemDrive%\inetpub\logs\LogFiles).
  3. Right-click on the folder and click Properties.
  4. On the General tab of the Properties page, click Advanced.
  5. Click Compress contents to save disk space, and then click OK.


If you want to go one step further and really want to remove log files after X time, I would recommend creating a small Powershell script and execute it using a Scheduled Task.

Friday, August 26, 2016

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">https://<resource> was not found in the tenant named <tenant>  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… Confused smile


Thursday, August 25, 2016

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:

Wednesday, August 24, 2016

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:

Tuesday, August 23, 2016

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 the Collection level
  • Go to the Security tab
  • Select the Project Collection Administrators group
  • Click on Members and add the user