Azure App Service, Development

How to serve WOFF fonts from Azure App Service

How to serve WOFF fonts from Azure App Service.

Solution:

1. Locate or create web.config

If you have asp.net application you will find the web.config but if you have hosted any other distrubution such as wordpress you can still create the web.config if this is not presented already.

2. Include/merge below code in web.config


  
    
      <mimeMap fileExtension="woff" mimeType="application/font-woff" />
      <mimeMap fileExtension="woff2" mimeType="application/font-woff" /> 
    
  

How to do it:

Go to Azure portal -> Locate your App Service -> Under Development Tools click on Advanced Tools -> click on Go link

How to serve woff font files from Azure App Service

A new tab will be opened and you will see Kudu logo, select Debug console and then CMD

Kudu click on cmd - How to serve woff font files from Azure App Service .png

Now navigate to the D:homesitewwwroot and find the web.config, if you find it then merge the code, else create it and copy paste the code mentioned in step 2.

In fact you can put any file extension you want to serve Azure App Service to serve as static file.

Merge web.config entreies - How to serve woff font files from Azure App Service.png

For more Details

Azure API Management, Cloud Computing

How to setup your Open API in Azure API management : Part 3

 

In this post, we are discussing, how to Get Started with Azure API Management, how we can automate API subscription and management using Azure API Management.

This post is a part of the Azure Services series, in this series, we will discuss about Microsoft Cloud Application Architecture and common cloud computing patterns to make application resilient and scalable. We will be using Asp.net MVC as our framework for applicable examples and Azure as cloud services provider.

You can find all the Microsoft Azure Services; we have covered already at Azure series.

How to setup your Open API in Azure API management : Part 3

In previous post we discussed, how to create your own Open API in Dot.net Core using swagger and published on Azure App Service.

In this post we are going to configure our Open API in Azure API management.

We had published our Open API on Azure App service, we are going to use it to configure it with Azure API management. In order to proceed we need to have Full URL of the json file generated by the swagger, in our case it is as below:

http://azureapimanagementv1.azurewebsites.net/swagger/v1/swagger.json

you can click on the URL marked below and it will take you to the swagger.json file.

Let go to the Azure Portal | Azure API Management instance | under API management click APIs | Click on OpenAPI Specification | and copy the URL of the swagger.json file.

Now go to Azure API Over view | click on publisher portal | APIs | Import API | select From URL | choose Swagger | choose New API radio button | mention the suffix URL, this could be name of your service | and choose the scheme, we are going for https | click save.

Now if you go to Azure API Management Instance | APIs , you could see that our service is available there.

Let us assign it to ultimate product, in Products text box type unlimited | choose unlimited | save | verify the API is associated with product by going to unlimited product, as you can see our API is listed there.

Now to use this API, all we need to do is subscribe, which in turn will generate the subscription id that can be used to call the service methods. Since in this series we already subscribed to the unlimited product so we can use our primary key to call the methods of our service.

Go to Overview in Azure API Management | click on developer portal | sign in | Click APIs tab | click on Azure API management API | click try it | fill the field | send

By default, Delete method is select so beware of this when you test the API on production.

You should receive the successful response as below.

Let us consume this service, create a new Asp.net Core Web application with the name client.

We will use NSwagStudio to generate client side classes for the C#, download the tool from below Address:

https://github.com/RSuter/NSwag/wiki/NSwagStudio
First get the swagger URL for the API. Go to developer portal | API tab | Click on AzureAPIManagementV1 | click on API definition | choose Open API | then copy the URL

Once NSwagStudio is installed, open the tool, mention the URL and check CSharp Client and either you can click on Generate output button and get the CSharp client code which you can copy paste in visual studio or you can generate the file for you. I copied the path to my client project including the cs file name which will be generated. If you are getting error while generating, try to run the tool as administrator.

If you go to your visual studio the File is already added for you, if the file is not visible use the add existing item option to include it in the project.

Now let us use this to call the API. Open, Index.cshtml.cs in Get method type below code:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Threading.Tasks;

using Microsoft.AspNetCore.Mvc;

using Microsoft.AspNetCore.Mvc.RazorPages;

namespace Client.Pages

{

public
class
IndexModel : PageModel

{

public
async
void OnGet()

{

System.Net.Http.HttpClient httpClient = new System.Net.Http.HttpClient();

httpClient.DefaultRequestHeaders.Add(“Ocp-Apim-Subscription-Key”, “ba210977b3374feb89caafefe28ba78d”);

MyNamespace.Client client = new MyNamespace.Client(httpClient);

System.Collections.ObjectModel.ObservableCollection<string> x = await client.ApiValuesGetAsync();

}

}

}

As you can see we need to include the Ocp-Apim-Subscription-Key
in default header.

If you debug you will get the proper response.

Azure API Management, Azure App Service

Auto documented API using Swagger in dot.net Core to integrate with Azure API Management : Part 2

In this post, we are discussing, how to Get Started with Azure API Management, How we can automate API subscription and management using Azure API Management.

This post is a part of the Azure Services series, in this series, we will discuss about Microsoft Cloud Application Architecture and common cloud computing patterns to make application resilient and scalable. We will be using Asp.net MVC as our framework for applicable examples and Azure as cloud services provider.

You can find all the Microsoft Azure Services; we have covered already at Azure series.

Auto documented API using Swagger in dot.net Core to integrate with Azure API Management : Part 2

In previous post we discussed, how the Azure API management tool work, briefly discussed Developer dashboard and subscription the Echo API.

In this post we are going to create our own API and set it up with Azure API management and consume it on client side.

Let us fire up our visual studio 2017, File Menu | New Project | Under Visual C# select .NET Core | Select Asp.net Core Web Application | click okay to create it.

Right click on Project in Visual Studio and choose the Manage NuGet Packages.

Click on browse tab, and search for Swagger, we will go for swachbuckle.aspnetcore, since we are using .net core so we need to choose Swachbukle.AspNetCore (this already include swaggerGen, UI and Swagger, so you don’t need to install each of them separately ) Package and install it.

Now add the following bold lines in the Startup.cs file

When we are using Swagger, we need to explicitly need to make sure our controller has Http verb attribute and for non-route parameters “From” body tag.

Under controller Directory | Open Values Controller | and verify that your code match as below:


 

Now we can run our application and see output. Since we have configured the c.RoutePrefix = “” that means the Swagger will open on the root of the site, navigate to the root site, in this example we will go to localhost:61300



As you can see under the Values, there are actions listed, but we do not have any documentation attached to them. Let us do just that.

Open the Values Controller class and add some details like below:

You can use triple forward slash to add summary tag for you, just press /// before the signature of the action and visual studio will add summary tags for you.


Now we need to enable these comments to show up in the swagger UI, Right click on Project | Properties | Build | check the XML documentation File.


Now we need to add using System.IO; in startup.cs

And add below lines of code as well, you may need to change the xml name if your xml file in build tab is different.

public
void ConfigureServices(IServiceCollection services, IHostingEnvironment env)

{


//services.AddMvc();

services.AddMvc().AddJsonOptions(options =>

{

options.SerializerSettings.Formatting = Formatting.Indented;

});

if (env.IsDevelopment())

{

services.ConfigureSwaggerGen(c =>

{


var xmlCommentsPath = Path.Combine(System.AppContext.BaseDirectory, “AzureAPIManagement.xml”);

c.IncludeXmlComments(xmlCommentsPath);

});

}

services.AddSwaggerGen(c =>

{

c.SwaggerDoc(“v1”, new Info { Title = “AzureAPIManagementV1”, Version = “v1” });

});

}

Now run the solution, you can see that the documentation is coming up.


Now our Basic API is ready, let us host it on Azure App Service, you can publish anywhere you want unless you get the Public URL of your API and then in next part we will configure it with API management and will use it on client side.

Right click on project | Publish | create new App Service | fill in the details | Click Create. It will take a little bit for time to publish for first time as it will create new app service for you.


After create | click on publish if it is not publishing already | you will see that after publish it automatically open the API URL in browser.


Next we will configure our API in Azure API Management, which is coming up next.

Azure API Management, Azure App Service

How to Get Started with Azure API Management : Part 1

In this post, we are discussing, how to Get Started with Azure API Management, How we can automate API subscription and management using Azure API Management.

This post is a part of the Azure Services series, in this series, we will discuss about Microsoft Cloud Application Architecture and common cloud computing patterns to make application resilient and scalable. We will be using Asp.net MVC as our framework for applicable examples and Azure as cloud services provider.

You can find all the Microsoft Azure Services; we have covered already at Azure series.

How to Get Started with Azure API Management : Part 1

The first question we get in our mind is, why to use Azure API management, what benefits it would give us, and why should we use it.
Azure API Management provide us the ability to create API gateway and developer portal, which is scalable, secure and can work with any host or API and it gives us insights of our APIs as well. The one thing most of us API developers struggle is, how to better manage on boarding process, documentation and provide easiest integration experience to our API’s end users /consumers/developers. This is the part, where Azure API management shines, it give us developer portal to manage the subscription of the services and provides a first-class developer experience. We will discuss all the functionality that Azure API Management provides and how to get most of it.

Let us create our Azure API management Instance first, usually it take a little bit longer around 30 mins to complete creation process.

Go to Azure portal dashboard, click create a new resource button | Search for API management | select API management | click create.

Now we need to fill the form, choose the pricing tier and click create. Let us look at pricing tier first; we have developer, basic, standard and premium tiers.

For Production, either go for basic or high tier since it will give you 99.9+ SLA uptime and options for scalability as well. Every tier support max request per second limitation, if you have only 1 API and 250 subscribers to the service then Basic tier will be sufficient if all 250 users send 2 request per second. From Developer to standard tier, it will only support single region, you can check which region is nearest to your customers/consumers by latency. If you have requirement to support multiple regions, then your only option is to go with Premium tier, and the price per month will increase drastically. Every tier also give us Redis cache as well and capacity is mentioned per instance, if you go for standard tier and you scale it up to 2 instances then you will have 1GB Redis Cache per instance totaling to 2 GB. Other things to consider is AAD integration and virtual network support, if you have need to connect with ADD then go for specific tier after evaluating price to value ratio and also consider virtual network support if you have API service hosted in VM in virtual network then consider it when you make any decision.

For our purpose, we are going with Developer tier, since we are not using it for production and it is giving us almost all the functionalities that other tiers give us except the scaling.

By default, the API management service will have a public URL yourdomain.azure-api.net but we can configure our own custom domain as well.

Creation process will take about 30+ minutes; it took around 38 mins to create in our case. Once the API Management Service is ready, you can see that

Click on developer portal link, will see the screen like below, currently developer/end users can sign up in this portal, the default sign in is configured by default to accept username and password. You can change this.

Go to your API Management Service in Azure Portal | Security | Identity, as you can see we have all the popular options such as Azure Active Directory, Facebook, Google, Microsoft as Identity provider. You may need to add or remove the Providers according to your business needs.

Go back to the Developer Portal and register with any secondary email, you will get confirmation email with link, click on the link to activate the user. Now login to the portal and navigate to the API tab. By Default, we have Echo API listed.

This window will show all the API that are available to consume, click on Echo API, you will see the window like below. By default, first resource is selected and in order to call this resource we need Ocp-Apim-Subscription-Key, you can get this key by subscribing to the Api. You can also click on Try it button to call the resource in the browser, we also have API Definition button if you want to download the API definition in WADL or Open API format.

Let us get our subscription ID, click on Products tabs, choose unlimited for now, we will talk about product later on and click subscribe and confirm the subscription.

Once you are done, a thank you email will be sent to you and you will see screen link below. Right now our unlimited product requires confirmation from Administrator side. So let us go to the Azure Portal and activate our subscription.

Back in the Azure Portal, click on Products | select Unlimited | subscriptions

We have two subscribers here, first one the API Management Service owner who have created this service, and second subscription entry is that we have just submitted earlier. Click on … button and choose Activate subscription and then click yes.

Now go back to Developer portal and refresh, you can see that subscription state is active now and you can also see the Primary key and secondary key.

Next step is to test the Echo service, click on APIS tab, select echo API and click on try. You can see now that the subscription key is automatically populated for you, you just need to click on send.

The response will be shown underneath of the send button.

Now let us create our own API and configure it with the Azure API Management, coming up next

Azure Cloud, Azure Cloud Services, Cloud Computing, Cloud development Patterns

Microsoft Azure cloud Application Development architecture and common cloud computing patterns to make application resilient and scalable

In this series, we will discuss about Microsoft Cloud Application Architecture and common cloud computing patterns to make application resilient and scalable.

We will be using Asp.net MVC as our framework for applicable examples and Azure as cloud services provider.

If you are new to azure development, check out Getting Started Azure development guide.

If you do not know where to start, please check my blog post, which covers detail about getting subscription and setting up. In this series, we assume that you already have active Azure subscription and Visual Studio 2013 or later installed on your system.

Since we are using Microsoft Azure cloud as cloud services provider, let us discuss the type of services azure provide us. First, we will discuss usual broad categories of services and then we will move to Azure specific services types. We can divide Microsoft Azure services into 3 broad categories such as below:

  1. Infrastructure as a Service
  2. Platform as a Service
  3. Software as a Service

Infrastructure as a Service

This is the basic providing of any cloud services provider; it is renting the IT Infrastructure for your use, it includes compute resources such as VMs for windows, Linux etc. Storage to store data, network resources such VPN etc. You have full control over the resources and it is your responsibility to apply the patches and do maintenance, although Microsoft provide you Service Level Agreement and guarantees the up time of the resources. You will mostly pay for resources you use with respect to time or number of unit consumed, and is usually called Pay as you go model, which we will discuss in detail later on in this series.

All these resources enable you to do what we call as lift and shift migration, you only need is to migrate all resources to cloud as it is. Infrastructure is the main building block and enable even cloud providers to provide as Paas, Saas and other services, which we look at next.

Platform as a Service

Every Cloud resource provider services, which enable developers to quickly deliver services/solutions  without need to manage the underlying infrastructure such as VM, storage, network. These providing are usually can be acquired on demand and can scale as your solution demand more resources. Payment model for these is the same as pay as you go or some time unit of consumption.

Software as a Service

In software as a service, usually vendors use cloud-computing provider’s services to develop solutions and expose their services as software. End users (you) of services do not need to worry about anything related to under lying infrastructure or to manage any resources, users just use the services over the internet using browser and payment method is usually subscription based. Office365 is a good example of Saas.

Now once we have passed the board categories discussion, let us move to exciting part of the services available to us on Microsoft Azure.

Microsoft Azure Cloud Services

Microsoft Azure Cloud provide a whole bunch of Cloud Services, some are listed below, and as the list is keep growing, we will keep adding them to the list.

Compute Networking Storage Web + Mobile Containers Databases Analytics
Virtual Machine Content Delivery Network StorSimple App Service App Service SQL Database HDInsight
Functions Azure DNS Data Lake Store Notification Hubs Container Registry SQL Data warehouse Apache Strom for HDInsight
Container Instances Traffic Manager Disk Storage Logic Apps Service Fabric SQL Server Stretch Database SQL Data Warehouse
Virtual Machine Scale Set VPN Gateway Queue Storage Live and On-Demand Streaming Batch Azure Database for PostgreSQL Event Hubs
Cloud Services Azure DDoS Protection Backup Content Protection Container Instances Azure Database Migration Service Log Analytics
Windows Virtual Machine ExpressRoute Site recovery Web Apps Azure Container Service (AKS) Azure Cosmos DB Data Lake Store
SAP Hana on Azure Large Instances Virtual Network Blob storage API Apps Redis Cache Azure Analysis Services
Batch Load Balancer Managed Disks API Management Table Storage Power BI Embedded
Service Fabric Application Gateway File Storage Media Services Azure Database for MySQL Apache Spark for Azure HDInsight
Azure Container Service (AKS) Network watcher Azure Search R Server for HDInsight
Linux Virtual Machines Encoding Stream Analytics
SQL Server on Virtual Machines Azure Media Player Data Factory
Azure Media Indexer Data Catalog
Mobile Apps Data Lake Analytics
Media Analytics Azure databricks
Content Delivery Network
AI + Machine Learning   Internet of things Integration Services Security and Identity Developer Tools Management Tools  
Machine Learning Studio Cognitive Services Azure Cosmos DB StorSimple Azure Active Directory Visual Studio Team Services Backup Automation and Control
Azure Bot Service Text Analytics API Machine Learning Studio Data Factory Azure Information Protection Application Insights Application Insights Network Watcher
Academic Knowledge API Computer Vision API Event Hubs Data Catalog Key Vault Hockey App Scheduler Microsoft Azure Portal
Content Moderator Emotion API Logic Apps Logic Apps Security Center API Management Log Analytics Cloud shell
Face API Bing Speech API Time Series Insights API Management Multi-Factor Authentication Azure DevTest Labs Azure Monitor Azure Policy
Web Language Model API Language Understanding ( LUIS ) IoT Edge Service Bus Azure Active Directory Domain Services Visual Studio App Centre Protection and Recovery Azure Management Applications
Speaker Recognition API Custom Speech Service IoT Hub SQL Server Stretch Database Azure Active Directory B2C Insight and Analytics
Bing Auto suggest Bing Spell Check API Stream Analytics Event Grid Azure Service health
Translator Speech API Translator Text API Notification Hubs Azure Resource Manager
Bing Custom Search API Bing Entity Search API IoT Suite Azure Mobile App
Bing Web Search API Bing Video Search API Event Grid Cost Management
Bing Image Search API Bing News Search API Azure Location Based Services Azure Migrate
Custom Decision Services QnA Marker API Blockchain Site Recovery
Knowledge Exploration Service Entity Linking Intelligence API Azure Advisor
Microsoft Genomics Video Indexer Automation
Linguistic Analysis API Azure Batch AI Traffic Manager
Custom Vision Service Machine Learning Services Security and Compliance

I know it is long list; and some items are duplicated as well under some headings, unbelievably, we are going to cover every one of the items listed above, and will discuss common cloud patterns for each item. As we go, we will keep adding the Icons for each discussed item, when a relative item’s post published on this site.

We are going to group some items in an implementation to cover real world scenarios and best practices as well as common cloud patterns while development, related source code will be available through GitHub.

This will be long and exciting journey, I hope you are ready, because we are about to get started.

Stay Tuned.