Tag Archives: API Management

Azure API Management: 200 OK response but no backend traffic

I’m noting this post down in the “if only someone had already made a big noise about this I might have saved some time” category.

The work I’m doing at present involves fronting some APIs with Azure API Management and then exposing them securely.

When I hit the moment I thought I was done today I was doing some testing, and no matter what I did I couldn’t get my backend service to respond, and I could clearly see no traffic hitting the backend.

After double-checking my policies and doing a few more tests (only a couple of hours) I then happened across this Stack Overflow question and its answer

It turns out that I had, somewhere along the line, removed the “forward-request” policy from the Policy applying to all APIs published via API Management.

So how to fix? As Darrell says, find the offending Policy and add the missing item back.

Edit Policy

When done it should like the image below.

API Policy

… and your API calls will now work as expected and not just give you back 200 OK! šŸ˜Ž

Tagged , , , , ,

Use Azure Management API SDK in an Entity Framework custom database initializer

A post over on Stack Overflow got me thinking about how you can override the default behaviour of the Entity Framework code first database initializer so that the tier of the database created is something other than the deprecated ‘Web’ tier. Here’s one way to go about it.

Required bits

There are a few things to get going here – you’ll need to add the the Microsoft Azure SQL Database Management Library nuget package to your solution which will install a bunch of dependencies required to interact with the Azure Management API.

You should also familiarise yourself with how to create and use Management Certificates which will be required for all interactions with the Azure Management API.

Once you’ve looked through that I suggest having a good read of Brady Gaster’s blogs on using the Management API in which he gives some good overviews on working with Azure SQL Database AND on how you can go about uploading your Management Certificate to an Azure Website.

For the purpose of the remainder of this post we’ll be using the sample MVC / EF code first sample application which can be downloaded from MSDN’s code site.

Now you’ve done that, let’s get started…

Create a custom EF initializer

Entity Framework provides a nice extensibility point for managing initialisation of databases amongst other items (primarily to allow you to use the latest hipster database of choice and roll your own supporting code) and we’re going to use a simple sample to show how we could change the behaviour we’re seeing above.

In the below sample we create Standard tier databases – we could just as easily change this to a configuration element and modify which database we wish to create. Note that I load a lot of information from configuration – in the below sample I can deploy those configuration elements at the Cloud Service level and manage via the Azure Management Portal. I could just as easily leave them in the web.config if I wanted to.

A sample of what appears in the configuration (this is from a web.config)

    <add key="AzureSqlDatabaseServerName" value="t95xxttjmj"/>
    <add key="AzureSqlDatabaseName" value="SchoolDemo"/>
    <add key="AzureSubscriptionId" value="00000000-0000-0000-0000-000000000000"/>
    <add key="AzureSubscriptionCertThumbprint" value="61b463082dcb0198aab451c14efb7ff4b83a42b4"/>

In our global.asax of our web application we then need to include the following code:

Database.SetInitializer(new ContosoCustomDatabaseInitializer());

At this point when EF attempts to fire up a new database instance it will call our custom code and initialise a new database on the specified server using the management libraries.

Hopefully in a future release we’ll see an update to the default database setting to use the new Standard tier instead.

Tagged , , , ,

TechEd 2014: Azure API Management Talk now available.

For those of you who didn’t get a chance to come along to my presentation on Azure API Management at TechEd in Melbourne this year the session is now up on Channel 9. Slides to go along with the session are also available.



Tagged ,

I’m speaking about Azure API Management at TechEd Melbourne 2014

Given the changes to TechEd this year and the smaller set of sessions available I’m exceptionally happy to be coming back for another year to talk more about Azure.

I’ll be speaking in Melbourne on 7 October on the topic “Microsoft Azure API Management: Win Friends and Make Money”. You can find out more about my session here: http://techedmelbourne.azurewebsites.net/SessionDetail.aspx?id=19015

Hope to see you there!

I'm speaking at TechEd Australia 2014

Tagged , ,

Before that Pizza-as-a-Service diagram there was Pizza Party

Look, I’m not even going to reproduce the diagram here. I know you’ve seen it. Everybody’s seenĀ it. Goodness knows my tweet stream has been full of it for the best part of the last month.

Just in case you haven’t seen it:Ā http://lmgtfy.com/?q=pizza-as-a-service

In doing my prep for my upcoming talk at TechEd Australia I came across this gem from April 2004 (yep, that’s over 10 years ago folks!) that shows how a public API can have a positive upside to any business, even if the usage is not strictly that which was intended.

The back story is that some guys worked out how to directly call Domino’s online ordering backend web service at the time without needing to drive it all through a web interface.

This small example really demonstratesĀ the power of a public API and how people will take it and use it in ways you had not intended, but in ways which will have a positive impact on your business.

What’s the bet that CompSci dorm rooms all over America in 2004 were happily ordering their delivered pizzas from a Linux command prompt?!


Check out the sourcecode up on Github!


Tagged , ,