Lance Larsen - .NET Architect Madison Wisconsin

All posts in Azure

Needed to add MP4 video support to an ASP.NET website project. 

Found that adding the following made that work great when I deployed to Azure.

<!-- ====================================================================== -->
<!-- Required to have Videos show up when deployed to Azure  -->
<!-- ====================================================================== -->
<staticContent>
  <mimeMap fileExtension=".mp4" mimeType="video/mp4" />
</staticContent>

Alas, when I refreshed the cache on my browser – all of my CSS and Javascript files would not load, with the dreaded 500 errors.

So apparently, as soon as you add any <staticContent> settings – you need to add all possible settings.  Counter intuitive, so wanted to share the a comprehensive non-trivial fix that worked for me.

If there’s a better way to do this – love to hear it…  Also may be a better way to do this in ASP.NET Core – but for now this is a pre-Core project.

Here’s the solution, hope it helps someone else.  Good coding :)

<!-- ====================================================================== -->
<!-- Required to have Videos show up when deployed to Azure  -->
<!-- ====================================================================== -->
<staticContent>
  <!-- Set expire headers to 30 days for static content-->
  <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00"/>
  <!-- use utf-8 encoding for anything served text/plain or text/html -->
  <remove fileExtension=".css" />
  <mimeMap fileExtension=".css" mimeType="text/css; charset=UTF-8" />
  <remove fileExtension=".js" />
  <mimeMap fileExtension=".js" mimeType="text/javascript; charset=UTF-8" />
  <remove fileExtension=".json" />
  <mimeMap fileExtension=".json" mimeType="application/json; charset=UTF-8" />
  <remove fileExtension=".rss" />
  <mimeMap fileExtension=".rss" mimeType="application/rss+xml; charset=UTF-8" />
  <remove fileExtension=".html" />
  <mimeMap fileExtension=".html" mimeType="text/html; charset=UTF-8" />
  <remove fileExtension=".xml" />
  <mimeMap fileExtension=".xml" mimeType="application/xml; charset=UTF-8" />
  <!-- HTML5 Audio/Video mime types-->
  <remove fileExtension=".mp3" />
  <mimeMap fileExtension=".mp3" mimeType="audio/mpeg" />
  <remove fileExtension=".mp4" />
  <mimeMap fileExtension=".mp4" mimeType="video/mp4" />
  <remove fileExtension=".ogg" />
  <mimeMap fileExtension=".ogg" mimeType="audio/ogg" />
  <remove fileExtension=".ogv" />
  <mimeMap fileExtension=".ogv" mimeType="video/ogg" />
  <remove fileExtension=".webm" />
  <mimeMap fileExtension=".webm" mimeType="video/webm" />
  <!-- Proper svg serving. Required for svg webfonts on iPad -->
  <remove fileExtension=".svg" />
  <mimeMap fileExtension=".svg" mimeType="images/svg+xml" />
  <remove fileExtension=".svgz" />
  <mimeMap fileExtension=".svgz" mimeType="images/svg+xml" />
  <!-- HTML4 Web font mime types -->
  <!-- Remove default IIS mime type for .eot which is application/octet-stream -->
  <remove fileExtension=".eot" />
  <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
  <remove fileExtension=".otf" />
  <mimeMap fileExtension=".otf" mimeType="font/otf" />
  <remove fileExtension=".woff" />
  <mimeMap fileExtension=".woff" mimeType="font/x-woff" />
  <remove fileExtension=".crx" />
  <mimeMap fileExtension=".crx" mimeType="application/x-chrome-extension" />
  <remove fileExtension=".xpi" />
  <mimeMap fileExtension=".xpi" mimeType="application/x-xpinstall" />
  <remove fileExtension=".safariextz" />
  <mimeMap fileExtension=".safariextz" mimeType="application/octet-stream" />
  <!-- Flash Video mime types-->
  <remove fileExtension=".flv" />
  <mimeMap fileExtension=".flv" mimeType="video/x-flv" />
  <remove fileExtension=".f4v" />
  <mimeMap fileExtension=".f4v" mimeType="video/mp4" />
</staticContent>

imageGreetings my Geeks – we have a lot of awesome ASP.NET Core 2.0 news coming out lately…

As always, sharing is caring – so here you go.

Today – after publishing to Azure – ran the default “Register” user page – and got the error message…

Swapping to Development environment will display more detailed information about the error that occurred.

Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application.

imageSo did a search for “ASPNETCORE_ENVIRONMENT” – and found the only references in my project were already set to “Development”…  so that wasn’t it…

imageEventually found a clue that that mentioned Azure App Settings – and yup – that’s where this needs to be set.

So click on your Web App –> Applications Settings –> go down to the “App Settings” section and add the “ASPNETCORE_ENVIRONMENT” and “Development” as displayed in the screen shot.

Now you’ll get the error messages as if you were running it locally – and that should help you resolve your issues.

REMEMBER – before you go to use this in production – revert that change.  Don’t want the bad guys to be able to see any error details.

Good coding!

Note: Valid values for “ASPNETCORE_ENVIRONMENT” are “Development”, “Staging” and “Production” – if you have something that’s not one of those, you may get odd behaviors… :)



imageMicrosoft is creating some very cool “Cognitive Services” that we as developers can easily utilize in our applications to accomplish some amazing results with a few simple calls to these Azure service.

If you haven’t setup the Cognitive Services – take a look at Setting up Azure Cognitive Services.

We’ll start with the “Face [Detection] API

“Detect one or more human faces in an image and get back face rectangles for where in the image the faces are, along with face attributes which contain machine learning-based predictions of facial features. … The face attribute features available are: Age, Gender, Pose, Smile, and Facial Hair…” 

As my eventual goal is to integrate these into Hololens for you guys – we’ll be doing this integration into UWP (Universal Windows Platform) – but starting with desktop apps.

Completed project is up on GitHub @ FaceApiUwp

Ok, let’s dive right into code!  Fire up Visual Studio…

Read more


imageI’m excited to start sharing a lot of research I’ve been doing for my upcoming Hololens development talks…

“Augmented Eyes = Azure Cognitive Services + Hololens”

Where to get started?

Note – everything I’m using including Azure and the Cognitive Services is free, no cost – so don’t hesitate to follow along and get everything setup!  My hope is that you’ll do some really cool stuff and “share-it-back” to our community. :)

1) If you don’t have one – you can sign up for a Free Microsoft Azure Account.

2) Once you have that, login to your Azure Portal.

image

Read more