CompositionalIT / farmer

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

ACR Managed Identity Support for Container Groups and Container Apps #977

Closed ahmed-ebaid closed 1 year ago

ahmed-ebaid commented 1 year ago

This PR closes #976

The changes in this PR are as follows:

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

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

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

let acrIdentity =  ResourceId.create (
                                 Arm.ManagedIdentity.userAssignedIdentities,
                                 ResourceName "msi",
                                 "<msi-resourcegroup>",
                                 "<msi-subscription>"
                             )
                             |> UserAssignedIdentity
let managedIdentity =
    {
        ManagedIdentity.Empty with
        UserAssigned = [ acrIdentity ]
    }
let farmerContainerGroup =
        containerGroup {
            name "farmercontainers"
            add_instances [
                containerInstance {
                    name "suave-script"
                    image "farmercontainers.azurecr.io/fsharpwebapp:1.0.0"
                }
            ]
            add_identity acrIdentity
            add_managed_identity_registry_credentials [ registry "farmercontainers.azurecr.io" "user" managedIdentity ]
            depends_on buildImage
            vnet myVnet
            subnet "msi-subnet"
        }
ninjarobot commented 1 year ago

Thanks for your contribution! This is now released in 1.7.9 and available on nuget.