How to include a non-standard font-face in azure hosted website without using visual studio? - azure

Trying to use a custom font in a simple static content website publish via git to azure. The website project isn't wrapped in a Visual studio solution. There is no web.config so how can I get the custom font to work or any static content such as .json files to be accessible?
This solution implies your using visual studio which I am not. How to include a non-standard font-face in azure?
My exact error is:
Failed to load resource: the server responded with a status of 404 (Not Found) http://fakewebsitename.azurewebsites.net/fonts/fontawesome-webfont.woff?v=4.0.3

you just have to add a MIME type for the font in your web.config it will look something like this for your woff font
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
</staticContent>
</system.webServer>
</configuration>
IIS by default will prevent download of static files you don't specify MIME types for.
Edit: added <remove fileExtension=".woff" /> based on #TealFawn suggestion

Related

Updating Azure App Service web.config to load .ttf font files

Wracking my brain but can't seem to find the solution. I have a .ttf font file, located on Azure storage blob, being used for a custom font on my Azure App Service site. I get a 404 "resource not found" error for this file.
After reading a ton of documentation on this, it seems I need to add a couple of lines of code, for a new "mimetype", to the web.config file. Older versions of Azure had this in "Extensions" or "Application Settings".
Other people show the ability to do so in Kudu under the "Debug" option. However, I can't seem to find either of those - "Configuration" shows environment variables and I don't see a "Debub" option in my Kudu portal.
Kudu Console without "Debug" option
How do I actually update the web.config file or at the very least be able to load a .ttf file???
Go to Kudu, then go to wwwroot folder and edit web.config file with the following, or just create one in case it's not there:
PS: previous image shows LogFiles folder, but it should be wwwwroot
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".ttf" />
<mimeMap fileExtension=".ttf" mimeType="application/octet-stream" />
</staticContent>
</system.webServer>
</configuration>

Is it possible to install fonts on an Azure App Service?

We are using MigraDoc/PDFsharp GDI+ which depends on having fonts installed to the system in order to render. We have tried embedding the fonts but the GDI+ version of MigraDoc does not seem to support this.
When trying to move this component to an Azure App Service, it cannot find the fonts. Is there a way to "install" the fonts locally to the App Service so that they would be visible to GDI?
MigraDoc uses PDFsharp to generate PDF files and PDFsharp can use fonts from embedded resources or from files read by the application.
I would use the WPF build of PDFsharp/MigraDoc 1.50 or later and use the IFontResolver interface.
You can use the generic EZFontResolver implementation if that suits your needs:
http://forum.pdfsharp.net/viewtopic.php?f=8&t=3244
A little late to this - but better late than never!
I have found out that this is actually quite easy - and we all know how!
Add a web.config to the WWWROOT of the app service
add the following
You probably don't need to have the < customHeaders > part unless you want CORS
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="false" />
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
<staticContent>
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<mimeMap fileExtension=".ttf" mimeType="application/octet-stream" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
</staticContent>
</system.webServer>
</configuration>
You can use a Windows Container on App Service for installing custom fonts. Here is how:
https://learn.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-windows-containers-custom-fonts
For getting started with Windows Containers on App Service:
https://learn.microsoft.com/en-us/azure/app-service/app-service-web-get-started-windows-container
As I know, Components rely on GDI API may not work on Azure Web APP. We could find this known issue at: https://social.msdn.microsoft.com/Forums/en-US/6ed5c738-390a-4ca7-81d0-370124a4fc88/azure-websites-faq?forum=windowsazurewebsitespreview. At currently, please try to use Azure Web role or Azure VM instead. Please also vote this idea on Azure feedback forum.

Can't get SVG served from Azure

I'm building a static HTML5 web site on VS2014 and deploying via Dropbox to be hosted on Azure. All works using F5 on VS2014. But my SVG images do not get served from Azure. I get HTTP/1.1 404 Not Found errors. I have tried this solution:
Use SVG in Windows Azure Websites and the code snippet suggested by Mads Kristensen at http://madskristensen.net/post/prepare-webconfig-for-html5-and-css3. My web.Debug.config & web.Release.config files are both as follows:
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.webServer>
<staticContent>
<remove fileExtension=".svg"/>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
</system.webServer>
</configuration>
Here's the question. What should I do to get my svg files to download?
EDIT: I found the problem. As a relative new user of VS2014 and Azure, I overlooked the higher level Web.config file and only worked with the lower two files mentioned above. Putting the additional staticContent lines into the Web.config file fixed everything.
I found the problem. As a relative new user of VS2014 and Azure, I overlooked the higher level Web.config file and only worked with the lower two files mentioned above. Putting the additional staticContent lines into the Web.config file fixed everything.

Google Earth (.kmz) mime type IIS issue

I am experiencing a peculiar issue with IIS and KMZ files. I have added the MIME type to IIS and it works just fine -- however, seemingly randomly the MIME type is removed. This has happened a few times now, and each time all I have to do to fix the issue is just add the MIME type again.
The issue is identified when broken links are reported, and as soon as I add the MIME type back in all is well.
Any thoughts on what is causing it, or methods for finding out what's causing it?
Thanks!
My guess is that someone is overwriting or modifying your web.config file. You can modify the web.config using either the IIS server tools or by publishing the project containing the web.config file. If you are modifying your IIS settings using IIS Manager, then every time someone re-publishes the web application it changes those settings. Make sure the correct settings are saved in your web.config in your root VisualStudio project. So that whenever that project is published it's setting the correct IIS settings.
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".kml" />
<mimeMap fileExtension=".kml" mimeType="application/vnd.google-earth.kml+xml" />
<remove fileExtension=".kmz" />
<mimeMap fileExtension=".kmz" mimeType="application/vnd.google-earth.kmz" />
</staticContent>
</system.webServer>
</configuration>

IIS only add MIME if not exist

I have - again - a problem in my WebAPI application.
I am trying to deploy on different versions of IIS (7, 7.5, 8). Newer versions seem to have a global MIME handler for .json, while older versions don't.
When IIS finds no MIME handler, the file does not exist. So, for the older version I made a local MIME handler in web.config.
The tricky part is: if it finds two of them (one global and one local), it stops working - even if they both are the same, IIS does not know which one to choose (wtf!?) and only throws errors.
Is there a switch I can apply in web.config which states that the MIME is only to be used if there is no other MIME for this extension available?
If not, can I tell VisualStudio to deploy different versions of web.config, depending on the deployment profile - and/or can I apply a IIS-version-based switch in web.config?
The easiest way to deal with this is to use the remove option for a mime mapping like this:
<system.webServer>
...
<staticContent>
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
</staticContent>
</system.webServer>
It's discussed in detail here:
http://blogs.msdn.com/b/chaun/archive/2009/12/04/iis7-error-cannot-add-duplicate-collection-entry-of-type-mimemap-with-unique-key-attribute-fileextension.aspx
There's also a reference to it here:
Add MIME mapping in web.config for IIS Express

Resources