Scheduling a feature toggle using no-code with Azure Logic Apps

Photo by Lorenzo Herrera

I use launch darkly to toggle features on an app. There is one third-party dependency that has regular scheduled maintenance and I need to toggle the feature on and off on schedule.

Launch Darkly has built in scheduling to handle this scenario but you have to be on the enterprise plan to use it. The enterprise plan is too expensive to upgrade to for scheduling alone so I needed to find a different way to automate this.

No-code on Azure

I had a couple of non-functional requirements that steered me towards a no code solution.

  1. I need to implement this quickly and move on to product features
  2. It had to have built in scheduling
  3. It needed to be easily maintained by anyone
  4. It needed to have easy access to change the schedule by anyone (a GUI for parameters)
  5. I had to be able to secure the Launch Darkly api key because we're writing feature values

Azure provides a no code type platform called Logic Apps that sounded perfect for this kind of workflow problem.


I'll describe each of the steps in detail so you understand why I had to add them.

I've provided the full JSON configuration at the end of this article so it's easy to recreate the logic app.

All of this can be set up using the Azure Logic Apps GUI. I'll add the json configuration for the steps where you can't see all the inputs in the screenshots.

Remember that copying this configuration wont work right away for you. You'll have to set up your own connections for the Azure Key Vault and Slack integrations using the logic app web UI.

The full logic app designer view

Here's everything together!

Top half of app designer

Bottom half of app designer

Okay, let's get started!

Add the logic app

Create a new Logic App in a resource group and you can use the consumption plan for this.

Add the Logic App parameters we will need

Open the parameter editor and add all these parameters. They're all strings.

Parameter nameDefault Value Description
ldEnvironmentKeyyour environment e.g. production
ldFeatureKeythe feature e.g. my-third-party-service
ldProjectKeythe project e.g. my-project
ldUserKeyuser id e.g. [email protected]
scheduleStartlocal time e.g. 2021-04-29T19:30:00
scheduleEndlocal time e.g. 2021-04-29T19:30:00

The lsUserKey is used to test if our trigger has actually set the variant off for a user.

Add the recurrence trigger

This app will check if an update is required every 30 minutes. Logic apps provide a super easy to use recurrence trigger for this kind of thing.

Add the recurrence trigger

  "triggers": {
    "Recurrence_Trigger": {
        "recurrence": {
        "frequency": "Minute",
        "interval": 30
    "type": "Recurrence"

Get Launch Darkly API key from Azure Key Vault

For security we store the Launch Darkly API key in an existing Azure Key Vault. Create a new Key Vault if you need it and then add the connection from Logic App action for reading Key Vault secrets.

Get Launch Darkly API key

Get the current status of the Launch Darkly feature

We need to make an http call to the launch darkly api. We use parameters to create the url and we add an authorization header from the Azure Key Vault secret.

Get the current status

"GET_current_feature_status": {
        "inputs": {
          "headers": {
            "Authorization": "@body('Get_Launch_Darkly_API_key_secret')?['value']"
          "method": "GET",
          "uri": "{parameters('ldProjectKey')}/@{parameters('ldEnvironmentKey')}/@{parameters('ldUserKey')}/flags/@{parameters('ldFeatureKey')} "
        "runAfter": {
          "Get_Launch_Darkly_API_key_secret": ["Succeeded"]
        "type": "Http"

Parse the JSON http response

The http call action doesn't parse the response. We have to use the JSON parser Logic App action to perform parsing. All of the properties will be available in later steps.

You need an example of the response to have the parser create a JSON schema for you. You can use postman or curl to request one time from launch darkly.

Parse the JSON http response

"Parse_LD_Response_Body": {
        "inputs": {
          "content": "@body('GET_current_feature_status')",
          "schema": {
            "properties": {
              "_links": {
                "properties": {
                  "self": {
                    "properties": {
                      "href": {
                        "type": "string"
                      "type": {
                        "type": "string"
                    "type": "object"
                "type": "object"
              "_value": {
                "type": "boolean"
              "setting": {}
            "type": "object"
        "runAfter": {
          "GET_current_feature_status": ["Succeeded"]
        "type": "ParseJson"

Convert the Start and End times to booleans

This is the same thing repeated twice so I'll just describe scheduleStart. scheduleEnd is the same pattern with different names!

To start use a time zone conversion to UTC because all the other Logic App actions use UTC.

Convert to UTC

Initialise a boolean variable

This will hold the result from testing if the scheduled time has passed.

initialise a variable

Test if the scheduled time has passed

Here we check if Now is greater than the scheduled time.

Test if time has passed

      "Detect_if_start_time_has_passed": {
        "inputs": {
          "name": "isScheduledStartTimePassed",
          "value": "@greater(ticks(utcNow()),ticks(body('Convert_schedule_start_to_UTC_time_zone')))"
        "runAfter": {
          "Initialize_start_time_variable": ["Succeeded"]
        "type": "SetVariable"

Now do the same three steps except use the END schedule parameter.

Check if we're within the scheduled period

So check if we're after the start time and before the end time. We can do this based on the previous variables we created. See the screenshot for how this is configured.

Are we within scheduled period

If we ARE in schedule check if the feature is currently on

The _value parameter here is from the Parse JSON action we did way up at the start. This is the state of the Launch Darkly feature right now.

If we are in schedule and it is currently ON (true) then we need to turn it OFF!

Is the feature currently on

Call the Launch Darkly API to turn off the feature

Here again we use parameters from the Logic App to generate the url. We use the authorization from Key Vault. There is an additional content type here because Launch Darkly's api uses a format of JSON patch.

The body has some required parameters, the key we want to change, the specific instruction to Launch Darkly and a comment to log what we're doing for auditing.

Turn off the feature in Launch Darkly

Get the latest feature state to verify our call worked

We get state of the key again to make sure we actually toggled the feature as expected.

Get the feature status from Launch Darkly

Parse this response from Launch Darkly

This is the same as the previous parsing step! We want to have the _value available later.

Parse the response

Send a message to slack channel

Where I work we use slack for all comms so we use the built in action to send a message to notify the team that the feature has been toggled.

You'll need to be an administrator on your slack to add the integration.

Once the integration is added you can set it to "send a message to channel".

The more info you add here the better imho! You can change the icon and bot name but using the "Add new parameter" selection drop down.

Send message to Slack

Now do the case where we're outside of schedule and feature is OFF

This means we need to turn the feature on. You can see in the full Logic App diagram screenshots below how this looks in my app. It's very repetetive so I won't go through every step again but you're turning ON the feature this time and your message to slack should reflect that.

Here you can see the instruction is "turnFlagOn".