ApolloServer, AzureFunctions and local debugging

I wanted to jog down some notes that’ll help with local debugging of Apollo Server with Azure Functions.

Firstly, due to changes to Azure API routing - specifically x-ms-privatelink-id having strange invalid characters - we need to expand the function handler and blank out the x-ms-privatelink-id property.

https://github.com/Azure/azure-functions-host/issues/6013

Now to get local debug happening - we must configure CORS.

Add the cors settings - origin can be ‘true’ for every url, or ‘http://localhost:4200’ if only for your local build.

Additionally, copy the access-control-request-headers to Access-Control-Request-Headers because ApolloServer applyMiddleWare is case sensitive.

https://github.com/apollographql/apollo-server/issues/4178

const graphqlHandler = server.createHandler({
    cors:{
        origin: true,
        credentials: true,
    }
});
export default (context: Context, req: HttpRequest) => {
    // https://github.com/Azure/azure-functions-host/issues/6013
    req.headers['x-ms-privatelink-id'] = '';
    // apollo-server only reads this specific string
    req.headers['Access-Control-Request-Headers'] = req.headers['Access-Control-Request-Headers'] || req.headers['access-control-request-headers'];
    return graphqlHandler(context, req);
}

These changes by itself isn’t enough, we also need to make sure the Azure Functions runtime is forwarding the options method correctly to our Apollo Server. Make sure ‘methods’ contains ‘options’ otherwise the Azure Functions local runtime will not accept the browser pre-flight request.

(this second one was the one that got me for a while - why wasn’t Apollo Server options being called?!)

{
  "bindings": [
    {
      "authLevel": "function",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req",
      "methods": [
        "get",
        "post",
        "options"
      ]
    },
    {
      "type": "http",
      "direction": "out",
      "name": "$return"
    }
  ],
  "scriptFile": "../dist/graphql/index.js"
}

Where to find John presenting in May 2020

We are living right now in a strange time. At home, and virtual events are replacing the traditional physical events.

I’ve agreed to several events and will be presenting all new (or freshly updated) topics for 2020. So while we remain physically distant, if you wanted to see one of my presentations - I’m actually a lot more visible.

May 01 - DC Power Apps & Power Automate usergroup - Why and How to implement Governance of the Power Platform

May 06 - Sydney Serverless meetup - Power Automate - Microsoft’s insane low-code serverless platform

May 11 - M365 May - Deep dive into Approvals in SharePoint and Teams with Power Automate

May 11 - USYD Cloud Society Azure/Power Up! - Intro Power Apps and Power Automate

May 15 - Sydney Power Apps and Flow usergroup - What’s new in Power Virtual Agents with Charles Sterling

May 16 - D365 Automation Saturday - Flow JAM Stack - how to build a complete low-code public website in 40 minutes

May 25 - UNSW Cloud Society - Azure/Power Up! - Intro Power Apps and Power Automate

May 26 - M365 May - Why and How to implement Governance of the Power Platform

May 27-28 - M365 Virtual Marathon - 5 Design Keys to make Flows run insanely fast

May 27-28 - M365 Virtual Marathon - Flow JAM Stack - how to build a complete low-code public website backed by M365

I’m still working on my YouTube series: How to build a public website with a Flow JAM Stack

Because of the events next week, I couldn’t work on an episode this week. But next Saturday’s Flow JAM Stack talk during the Automation Saturday will be a 40 minutes compressed teaser. Hope to catch you at one or many of these upcoming events.

Flow JAM Stack Episode 1 - sending data back with Flow as API

In this follow on episde, we dive a fair way in to see how we can customize Flow’s Request trigger to build a web service (API endpoint) that can be called from our static website.

Episode 1

  • Create a Flow service

  • Configure the form input params

  • Configure the service return HTML Redirect

  • Talk about embedding HTML FORM in static sites, but also hosted site scenarios - SharePoint, Power Apps Portal Apps, WordPress, SquareSpace.

We are deliberately going slowly going through some pitfalls and errors that you may see along the way, so the episode is progressing slowly, but I hope that’s the right direction to do this - we make sure there’s a firm foundation before moving to the next step.

I had initially hoped to get into API management, but it looks like that’ll be in a future episode.

In this episode, we extend the application with a HTML Form that will send messages back to Flow, which we then store into our backend datasource. If you hav...


Building modern public sites (JAM Stack) with Microsoft Flow

Web technologies evolve, and we are on the edge of a new stack, it is called JAMStack.

  • Javascript

  • API

  • Markup

In the world of JAM Stack, we create serverless public sites by hosting them directly from a CDN.

Now there are plenty of frameworks that will move to help developers to create this type of applications right now and next.

What I’m writing about is how citizen developers can take advantage of the same pattern to build public websites

Episode 0

  • Define JAM Stack

  • Set up data source (SharePoint)

  • Set up API (Flow)

  • Set up Storage (Azure Storage)

  • Set up CDN (Cloud Flare)

  • Set up dynamic trigger


Whether you are a Professional Developer or a Citizen Developer - you need to understand the basics of this stack. This will save you a LOT of money.

How we can use Microsoft Flow (Power Automate) to build public websites. This is a how-to video that involves defining the JAM Stack, Microsoft Flow, Azure B...

Using Flow to create Microsoft Teams online events via Microsoft Graph

I had a Flow hack a while back to have a Flow button that will instantly create an online teams meeting. Recently, I adapted it into a trigger event that turns my Outlook calendar events (where I’ve forgotten to make it a meeting) into an online meeting.


The techniques needed a bit more exploration, so I did that, and recorded it as a quick 15 minute recording on my YouTube channel. Enjoy!

This is a Flow (Power Automate) that uses Microsoft Graph to create a Teams meeting event invitation. You can use this to invite people inside or outside of ...