Skip to content

Azure App Configuration / Feature Flags#1244

Open
Ryan-Palmer wants to merge 2 commits intoCompositionalIT:masterfrom
WieldMore-io:azconfig-feature-flags
Open

Azure App Configuration / Feature Flags#1244
Ryan-Palmer wants to merge 2 commits intoCompositionalIT:masterfrom
WieldMore-io:azconfig-feature-flags

Conversation

@Ryan-Palmer
Copy link
Copy Markdown
Contributor

This PR closes #387

The changes in this PR are as follows:

  • Azure App Config builder
  • Feature Flag builder

I have read the contributing guidelines and have completed the following:

  • Tested my code end-to-end against a live Azure subscription.
  • Updated the documentation in the docs folder for the affected changes.
  • Written unit tests against the modified code that I have made.
  • Updated the release notes with a new entry for this PR.
  • Checked the coding standards outlined in the contributions guide and ensured my code adheres to them.

If I haven't completed any of the tasks above, I include the reasons why here:

I'll update docs and tests once the general implementation has been given the thumbs up.

Below is a minimal example configuration that includes the new features, which can be used to deploy to Azure:

open Farmer
open Farmer.Builders
open Farmer.Arm

let configStore =
    configurationStore {
        name "azConfigFarmerTest"
        sku ConfigSku.Developer
        feature_flags [
            {
                Name = "TestFlag"
                Description = "A test feature flag"
                Label = "Flag label"
                State = true
            }
            {
                Name = "TestFlag2"
                Description = "Another test feature flag"
                Label = ""
                State = false
            }
        ]
    }

let deployment = arm {
    location Location.NorthEurope
    add_resource configStore
}

deployment
|> Deploy.execute "test-farmer-config" Deploy.NoParameters
|> printfn "%A"

Copy link
Copy Markdown
Collaborator

@ninjarobot ninjarobot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing this @Ryan-Palmer. I made a few requests for adjustments.

let enabled = this.State |> string |> _.ToLower()

let featureFlagValue =
$"""{{"id":"{this.Name}","description":"{this.Description}","enabled":{enabled}}}"""
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is freeform text, so it will need JSON escaping. One quick way would be like:

[
  "id", box this.Name
  "description", this.Description
  "enabled", enabled
] |> dict |> System.Text.Json.JsonSerializer.Serialize

type ConfigurationStoreBuilder() =
member _.Yield _ = {
Name = ResourceName.Empty
Location = Location.NorthEurope
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be in the builder - it will get set on the resulting resource in the BuildResources call.


/// Disables local authentication for the configuration store.
[<CustomOperation "disable_local_auth">]
member _.DisableLocalAuth(state: ConfigurationStoreConfig, disable: bool) = {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this member is called "disable_local_auth", it doesn't need the boolean argument and should just set DisableLocalAuth to true when the operation is called.


/// Sets the location of the configuration store.
[<CustomOperation "location">]
member _.Location(state: ConfigurationStoreConfig, location) = { state with Location = location }
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can also remove this location operation since this is set automatically with by BuildResources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for Azure App Configuration

2 participants