CompositionalIT / farmer

Repeatable Azure deployments with ARM templates - made easy!
https://compositionalit.github.io/farmer
MIT License
514 stars 156 forks source link

Create b2c tenant #1095

Closed amine-mejaouel closed 4 months ago

amine-mejaouel commented 5 months ago

This PR closes #

The changes in this PR are as follows:

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

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.Deploy

let initialDomainName = "myb2c"

let myb2c =
    b2cTenant {
        initial_domain_name initialDomainName
        display_name "My B2C"
        sku B2cTenant.Sku.PremiumP1
        country_code "FR"
        data_residency B2cDataResidency.Europe
    }

let b2cDoesNotExist (initialDomainName: string) =
    let output =
        Az.AzHelpers.executeAz $"resource list --name '{initialDomainName}.onmicrosoft.com'"
        |> snd
    not (output.Contains initialDomainName)

let deployment =
    arm {
        location Location.FranceCentral
        add_resources
            [
                // This allows to avoid having an error when the B2C tenant already exists
                if b2cDoesNotExist initialDomainName then
                    myb2c
            ]
    }
ninjarobot commented 4 months ago

Thanks for the contribution @amine-mejaouel - this is in the 1.8.7 release available on nuget.