Friday, January 23, 2015

Azure WebJobs: Log location

A colleague asked me where he could find the logs of Azure WebJobs he configured inside an Azure Website.

For every Azure Website you create a Kudu dashboard exist. To get to this website browse to https://{site name}.scm.azurewebsites.net (in other words, add .scm in front of your Azure website name).

image

Click on the Debug console menu item and choose the CMD option. The Kudu Remote Execution Console is loaded.

image

You can now browse to the correct log location either by using the command line or by clicking through the folders at the top. Log files for the Azure Webjobs can be found under d:\home\data\jobs

image

More information about Azure Website logging can be found at:

Thursday, January 22, 2015

Angular.js: Return a promise that is already resolved

I have an Angular service that either should return an existing object or call a webservice and load some data. To have a consistent client API I want to use a promise in both cases.

It’s not very hard to do this using Angular:

Wednesday, January 21, 2015

Bootstrap Progress bar

Today I lost some time searching why I couldn’t get the Bootstrap Progress bar working.

The problem is that the sample on the Bootstrap site(http://getbootstrap.com/) isn’t up-to-date for the latest Bootstrap version(Bootstrap 3.3.1). Here is the sample code as of today:

image

Instead the correct code should look like this:

Tuesday, January 20, 2015

Restier: Bringing WCF Data Services and Web API OData together

Microsoft is working on a new framework called Restier:

RESTier is a RESTful API development framework for building standardized, OData V4 based REST services on .NET. It can be seen as a middle-ware on top of Web API OData. RESTier combines the convenience and simplicity of WCF Data Services alongside the flexibility and extensibility of Web API OData.

Similar to a WCF Data Service it exposes your Data Model through a REST service. 

Get started.
  • Create a new MVC application
  • Add an Entity Framework Code First context
  • Include the Microsoft.Restier NuGet Package(don’t forget to set Include prerelease)

image

  • Create a Domain class that wraps your DbContext:
  • Add a Web Api controller inheriting from ODataDomainController that wraps the Domain class:
  • As a last step add an extra route to the WebApiConfig file:
  • If you run the application and browse to /api/northwind, you can see the available entity sets:

image

Monday, January 19, 2015

Interested in a coding challenge? Check www.codehunt.com

The guys from Microsoft Research who created Pex, also created www.codehunt.com.

You are an experimental application known as a CODE HUNTER.

You, along with other code hunters, have been sent into a top-secret computer system to find, restore, and capture as many code fragments as possible.

Your progress, along with your fellow code hunters, will be tracked. Good luck

CodeHunt.com is a coding game that asks you to update code fragments so that all tests succeed. The more efficient your code, the more points you score. Behind the scenes it is using the Smart Unit Tests feature. Certainly a good and fun way to improve your coding skills.

Ready to beat my record? :-)

image

Friday, January 16, 2015

MSDN Subscription now offers access to a range of Pluralsight courses

If you have a MSDN subscription today, I have some good news for you. Starting from this year, subscribers receive a 12-month Pluralsight training benefit as part of its MSDN subscription. The number of courses included in this benefit depend on the type of MSDN subscription. Here is a sample:

CourseCatalog

Information how to activate this benefit can be found here; http://blogs.msmvps.com/deborahk/msdn-now-includes-pluralsight-courses/.

Thursday, January 15, 2015

ASP.NET MVC file download: correctly set mime type

In an MVC application, we are offering the functionality to download files. This is easy thanks to the built-in FileResult class.

The only caveat is that we have to support a wide range of file formats. To make the browser react correctly it’s important to set the correct MIME type in the response. Before ASP.NET 4.5 you had to build your own list of mappings between a file extension and the related MIME type. Luckily, in .NET 4.5, this is no longer required.  The MimeMapping class exposes a public static method called GetMimeMapping which takes in a file name (or extension) and returns the appropriate MIME type: