A way to manually kick a Azure Function Timer Trigger Function when its been deployed


Introduction

At iThink 365 we have been building a few products around the Microsoft 365 Employee Experience. These products need to refresh information about the employees and so this is done using Azure Functions as Timer Trigger functions.

Something like this

Last week, I was chatting with one of my team and I showed them how they could manually kick off the timer trigger function. They exclaimed, “Woah, I had no idea you could do that!” I asked some more of the team and they said the same thing. So, I hope you have not either.

One of the attributes on the Timer Trigger is the RunOnStartup flag and it is important and seen as one of the best practices of Azure Functions to make sure that these are switched off,. This ensures that you don’t get your Azure Function firing randomly.

However, when developers are working on these Timer Triggers you want the Timer Trigger to run as soon as you start debugging the code. Having the RunOnStartUp flag off is a pain and often they get left on so that the code runs on startup. We do not want that behaviour where the flag gets left on.

Another scenario that you want to kick off the Timer Trigger is when a new customer joins and you want their user estate to be processed as soon as they subscribe to your product.

So, we need to be able to kick off the Timer Trigger function somehow.

How do we manually kick off a Timer Trigger function?

Solution

Well, it turns out you can call the Azure Function with a special endpoint and it is this one.

Using the URL:

https://%5Byour azure function url]/admin/functions/[YourAzureFunctionTimerTriggerFunctionName]

For our timer job above it would be like this:

https://doyfunction.azurewebsites.net/admin/functions/RefreshNewStartersCachesFunction

You can kick off the Timer Job, you also need either the master key or the function key from your Azure Function.

This can be retrieved by:

  • Browse to the Azure Portal (https://portal.azure.com)
  • Find your Azure Function
  • Click on App Keys under Functions
  • Copy the master key

Once we have the Azure Function function/master key, we need to call the endpoint. To do that we:

  • Using Postman
  • Create a request
  • Change the HTTP verb from GET to POST
  • Use your URL for your Trigger Function
  • Add a new header called
    • x-functions-key
  • use the function or master key as the value.
  • Click Send
  • You will receive an Accepted 202 response back if the request was successful.

That is it your timer job will have started.

An example is here:

If you receive an HTTP 404, and you are using an Application Setting to define your Timer Trigger schedule then check you have a valid value for the Application Setting in your configuration.

Hope you find this useful!

Azure Synapse Link for Dataverse gets stuck “Fetching app…”


Introduction

In this post I am documenting the approach that we took to fixing an issue when setting up the Azure Synapse Link for Dataverse.

We followed the instructions that Microsoft laid out which are detailed in this post,

Create an Azure Synapse Link for Dataverse with your Azure Synapse Workspace.

It is important to get the permissions right within Azure for the Blob Storage rights to the Azure Storage Account.

The problem was when we set up the Azure Synapse Link for Dataverse, after you choose your tables and click Save. The setup would start but get stuck with a message saying “Fetching app….” at the top of the screen. I waited and waited but nothing happened.

An example is shown below.

After a lot of head-scratching and checking the documentation, we ended up launching a call with Microsoft Support.

Microsoft Support to the rescue

Our support engineer, Kristiana, asked us to create network traces and eventually, we could see a request to Azure AD Application failing for app id: f3b07414-6bf4-46e6-b63f-56941f3f4128.

Kristiana came back to us and said that we were missing an Azure AD sorry Microsoft Entra Service Principal for Power Query.

The fix was the following:

Prerequisites:

User with privileges to create a service principal in Azure tenant (Tenant admin):

o Application Administrator
o Global Administrator

Create principal in the Azure tenant:

  • Launch Powershell
  • Connect to the tenant by running the following command; you’ll be prompted to authenticate. Login using credentials for the Azure tenant admin
  • Connect-AzAccount 
  • The subscription shouldn’t matter as we’re adding a new service principal to the tenant
  • Add the principal by running the following command
  • New-AzADServicePrincipal -ApplicationId ‘f3b07414-6bf4-46e6-b63f-56941f3f4128’

The Azure Synapse Link process was tried again and it worked, after a few weeks of trying we had a successful Azure Synapse Link setup!

Anyway hope that helps.