Monday, April 24, 2017

Angular 2 Pipes– args are not arguments :-)

Today I lost some time investing an issue with Angular 2. I was creating an Angular pipe using Angular CLI. The code that was generated for me was the following:

Unfortunately I wrongfully assumed that the args keyword was refering to the arguments object we have in the JavaScript language. Turns out that this was a wrong assumption. Since Angular beta.16 the parameters are not passed as array to the transform() method anymore but instead as individual parameters:

{{ myData | translate:'arg1':'arg2' }}


export class TranslatePipe implements PipeTransform {   
  transform(value:any, arg1:any, arg2:any):any {
        ...
}

I would suggest to the Angular CLI team to change the name of the argument, because the args name causes confusion. Or is it just me?

Friday, April 21, 2017

Use Swagger-UI to test your Open API

In case your REST api exposes an Open API specification document, but you didn’t integrate Swagger UI to allow developers to browse and test your API, they can still use the Swagger-UI capabilities by directly browsing to http://petstore.swagger.io and put the url in the box at the top of the page. Alternatively, they can add the url of the service to the end with ?url= such as http://petstore.swagger.io?url=https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v2.0/json/api-with-examples.json.

image

Thursday, April 20, 2017

ASP.NET Core Web Deploy–XML Documentation files are not copied

After deploying our ASP.NET Core application using Web Deploy, we noticed a problem with our Swagger integration through SwashBuckle. Normally SwashBuckle can integrate documentation in your Swagger UI by extracting and reading the XML comments added to your code.

Problem was that when this XML isn’t copied Swashbuckle throws an exception making our whole API unavailable. Some research showed that the problem appeared after migrating from the project.json format back to csproj, after which the <DocumentationFile> was no longer automatically copied to the output folder during the build or publish process.

The solution I used was to add the following snippet to your csproj:

Wednesday, April 19, 2017

TFS Release error - WinRM cannot complete the operation.

After creating a release pipelin in Team Foundation Server, I got the following error during deployment: 
Connecting to remote server failed with the following error message : WinRM cannot complete the operation. Verify that the specified computer name is valid, that the computer is accessible over the network, and that a firewall exception for the WinRM service is enabled and allows access from this computer. By default, the WinRM firewall exception for public profiles limits access to remote computers within the same local subnet. For more information, see the about_Remote_Troubleshooting Help topic.
As the error mentions first thing to check if I can use WinRM to invoke Powershell remotely. Therefore login on the target server and execute the following command:
  • winrm quickconfig

image

  • I said yes to apply the suggested changes

image

And indeed, no exception was configured on the firewall to allow access from remote computers. The winrm quickconfig did all the work for me to fix the situation. Nice!

Tuesday, April 18, 2017

ASP.NET Core 1.1 –Error in Response Caching Middleware

After putting a first version of our ASP.NET Core application into acceptance, we got a strange bug back.

Sometimes after a cold start, users mentioned that the dropdown lists inside the application were empty. The application is using the Response Caching middleware to prevent having to fetch those lists over and over again from the database.

When looking at the server logs, we found the following error message:

exception": "System.ArgumentException: An item with the same key has already been added. Key: \r\n at System.ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException(Object key)\r\n at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add)\r\n at System.Collections.Generic.Dictionary2.Add(TKey key, TValue value)\r\n at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.FrameResponseHeaders.AddValueFast(String key, StringValues value)\r\n at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.FrameHeaders.System.Collections.Generic.IDictionary<System.String,Microsoft.Extensions.Primitives.StringValues>.Add(String key, StringValues value)\r\n at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.FrameHeaders.System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,Microsoft.Extensions.Primitives.StringValues>>.Add(KeyValuePair2 item)\r\n at Microsoft.AspNetCore.ResponseCaching.ResponseCachingMiddleware.d__10.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()\r\n at Microsoft.AspNetCore.ResponseCaching.ResponseCachingMiddleware.d__11.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---

Seems there is a bug in the Response Caching Middleware, the response caching middleware is causing an exception when it tries to add the same header. This is a bug that should be fixed in  the ASP.NET Core 1.1.1 patch.

Monday, April 17, 2017

Canvanizer

Last year our CEO gave a session about ‘Business Model You’, or how to create your personal business model canvas. I really liked the session and how it made you think about your strenghts, weaknesses and the value you create for your company and customers.

I’m still using this approach today. Last week I found Canvanizer, a free tool that simplifies the creation of a Business Model canvas.

image

Friday, April 14, 2017

Using the Visual Studio 2017 Offline Installer

Visual Studio 2017 offers a new installation experience with better modularity, a smaller footprint and quicker results.

As a consequence, you no longer have a big ISO file containing all possible components, instead you get a small exe and all other files are downloaded on the fly.

Visual Studio 2017 setup dialog

Works great unless you need to install Visual Studio when you don’t have Internet access. An offline installer can be created by following the steps as described here: https://docs.microsoft.com/en-us/visualstudio/install/create-an-offline-installation-of-visual-studio

Afterwards you can copy the generated offline installer(some executables and a large list of packages) to the location where you want to use it. What is really important is that you first install the provided certificates(they are in the Layout\Certificates folder). The certificates don’t have a password, so just keep clicking next until the installation completes. If you don’t install the certificates first, we noticed that the installer still tries to go online to download the packages.

Afterwords you can run the installation exe.

Thursday, April 13, 2017

Angular CLI–Include a static html file

While integrating OIDC into my Angular app, I had to add a separate authentication page(originally named auth.html). However after bundling and serving my application using ‘ng serve’ I noticed that I couldn’t reach my ‘auth.html’ file and I got an error message instead…

The solution was obvious, any extra files you want to include should be added to the assets section inside the angular-cli.json file:

Wednesday, April 12, 2017

Azure API Management–Mock your service

A nice addition to Azure API Management is the mock-response policy. It allows developers to call your API without invoking the real backend service.

Here are the steps involved to configure mocking from the Azure Portal:

  • Browse to the Azure Portal
  • Open an API Management instance.
  • Click on APIs.

image

  • Click on an API

image

  • Then, for the scope of either All operations or any particular operation, open the Inbound processing editor.

image

  • A new tab titled Mocking is now available.

image

  • Change the Mocking behavior to Static responses and choose a Response from the list

image

Tuesday, April 11, 2017

Visual Studio 2017–.editorconfig

Visual Studio 2017 adds support for .editorconfig files within projects to help developers define and maintain consistent coding styles between different editors and IDEs, which can be useful for large development teams looking to maintain a consistent style across their code base.

Teams can configure convention preferences and choose how they are enforced inside the editor (as suggestions, warnings, or errors). The rules apply to whatever files are in the directory that contains the EditorConfig file. If you have different conventions for different projects, you can define each project’s rules in different EditorConfig files if the projects are in separate directories.

More about the EditorConfig project: http://editorconfig.org/

Easiest way to get started is by installing Mads Kristensen's EditorConfig extension, which can be downloaded from the Visual Studio Marketplace and will provide full autocompletion, syntax highlighting, and much more.

Remark: You don’t need this extension but it makes editing the .editorconfig files so much easier

After installing the extension it is time to open Visual Studio and load a solution.

  • Right click on a project. Choose Add –> .editorconfig File

image

  • Thanks to the extension you’ll get autocompletion

image

If you do not wish to use an EditorConfig file or you want to configure rules that your team hasn’t explicitly set, go to Tools>Options>Text Edtior> [C#/Basic]>Code Style to configure your machine local settings.

image

More information: https://docs.microsoft.com/en-us/visualstudio/ide/create-portable-custom-editor-options

Monday, April 10, 2017

#MakeWhatsNext–A cry out for more diversity in IT

I find it really unfortunate how little diversity there remains in the IT world. An era ago there were more women in IT than today! Something has to change…

We all play a role to change this and education will be one of the key pillars. Time to support #makewhatsnext

Friday, April 7, 2017

Avoiding seagull architects

During one of my trips to work I was listening to a DotNetRocks episode with Mark Seemann(this one to be precise: http://dotnetrocks.com/?show=1418).

In this episode Mark mentioned a ‘seagull architect’:

A seagull architect swoops in, poops out a lot of powerpoints, then flies off to let others implement it, evolve it, and solve the real problems.

This term comes from a book called Behind Closed Doors – Secrets of Great Management, a book that I immediatelly added to my reading list. Smile

Cover image for Behind Closed Doors

Thursday, April 6, 2017

TFS 2017 - VS402642: Found a backup job running against Tfs_DefaultCollection database

Last week during a TFS upgrade we noticed that the upgrade for one of the collections failed with the following error message:

VS402642: Found a backup job running against Tfs_DefaultCollection database. Wait for the backup job to complete and then rerun the failed collection job from the Status tab

Before starting the upgrade the sys admins already configured the backup jobs which intervened with the upgrade that was going on.

We were first afraid that we had to restart the whole upgrade procedure but it turns out that the TFS upgrade procedure is a lot more robust. As we were able to upgrade all the other collections and the configuration database, we had a working Team Foundation server system available. Only this one collection was missing.

To fix it, we first disabled all configured jobs inside the SQL Server instance.

Next step is to rerun the upgrade procedure for this collection:

  • Log in on the Team Foundation Server application tier
  • Open the Team Foundation Administration Console
  • Click on the Team Project Collections tree item on the left

image

  • Click on the collection that has failed to upgrade from the list on the right. The State would normally show as ‘Offline’

image

  • Go to the Status tab

image

  • Select the upgrade job from the list(normally the one on top of the list) and click Rerun job.

image

Wednesday, April 5, 2017

Team Explorer is back

Visual Studio 2013 and before had a seperate installer for Team Explorer. This allowed non-developers to access Team Foundation Server and all it’s functionality without the need to install a Visual Studio version. In VS 2015, Microsoft did not release a standalone Team Explorer but pointed customers to the free Express SKUs and Community editions, which included Team Explorer functionality.

This week with the Visual Studio 2017 Update release, the standalone Team Explorer installer is back. This is a free download for non-developers who connect to Team Foundation Server or Visual Studio Team Services.

Remark: Note that you probably still need a CAL(client access license).

Tuesday, April 4, 2017

Manual install of the Java JRE

Today I had to install the Java JRE on a server to be able to use ElasticSearch. Unfortunately I couldn’t install any software that allowed me to extract and run the tar.gz file on the server.

Here is my workaround:

Download and extract

  • Start by downloading the Java 8 Server JRE.
  • Once downloaded, unzip the tar.gz file. You’ll get a tar file.
  • That tar file should be unzipped again. The output of this second unzip operation was a set of binaries and executables.
  • Copy these files over to a file share on the target server.

Installation

  • Create a folder C:\Program Files\Oracle Java Server on your server.
  • Browse to the content of the file share.  Go one level deeper e.g. jdk1.8.0_XX (where XX is the current update version) and copy this content to the new folder on your server.

Set JAVA_HOME environment variable

Finally we need to set an environment variable to point to our new Java installation:

  • Open the System Properties.
  • Click the Advanced tab and the Environment Variables button.
  • Click New... at the System Variables.
  • Use JAVA_HOME as the name of the variable and the path C:\Program Files\Oracle Java Server as the value.
  • Finish this job by clicking OK until your are back at the control panel.

That’s it!

Monday, April 3, 2017

Reporting Services 2014 upgrade error

After upgrading to SQL Server 2014, we encountered the following issue while configuring the Reporting Services:

When we tried to restore the Reporting Services Encryption key, it always failed. Inside the error logs we found the following information:

The version of the report server database is either in a format that is not valid, or it cannot be read. The found version is ‘163’. The expected version is ‘162’. (rsInvalidReportServerDatabase).

A quick search on the web brought us to the following post: https://blogs.msdn.microsoft.com/sql_server_team/upgrading-to-sql-2014-report-server-version-mismatch/

The problem can happen when you upgrade from a SQL 2012 SP2 server with CU5 or later, the database will have a higher version number than what SQL 2014 expects.

Luckily there was already a solution out there. I asked the server team to upgrade to SQL 2014 CU7 after which the issue was gone…