Gallery

Overview

The gallery builder is used to create Galleries for sharing VM images. These can be used to create virtual machines or virtual machine scale sets that can expand or contract to scale capacity as needed.

  • Galleries (Microsoft.Compute/galleries)
  • Gallery Images (Microsoft.Compute/galleries/images)
  • Gallery Applications (Microsoft.Compute/galleries/applications)
  • Gallery Application Versions (Microsoft.Compute/galleries/applications/versions)

Builder Keywords

Applies ToKeywordPurpose
gallerynameName of the gallery resource, up to 80 characters, alphanumerics and periods.
gallerydescriptionDescription for the gallery.
gallerysharing_profileSharing profile that must be set to share with the community or groups.
gallerysoft_deleteIndicate soft deletion of images should be enabled or disabled (default disabled).
galleryadd_tagsAdd tags to the gallery resource.
gallerydepends_onAdd explicit dependencies for the gallery resource.
galleryImagenameName of the image in the gallery.
galleryImagegallery_nameName of the gallery where the image is created.
galleryImagegallerySpecify the gallery in the same deployment. The image will depend on the gallery.
galleryImagearchitectureIndicates x64 or ARM 64 images - defaults to x64 if not set.
galleryImagedescriptionOptional description for the image in the gallery.
galleryImageeulaOptional End User License Agreement for using the image.
galleryImagehyperv_generationThe Hyper-V generation for the image. This should be set to match the Hyper-V generation of the source image that was used to create this image.
galleryImagegallery_image_identifierThe publisher, offer, and sku for the image in the gallery.
galleryImageos_stateIndicate if the VM is Generalized or Specialized. A generalized image allows OS configuration options, such as setting the username and password, whereas this is typically set already in a specialized image.
galleryImageos_typeOS type for the image - Windows or Linux
galleryImageprivacy_statement_uriURI where the privacy statement for the use of the image can be found.
galleryImagepurchase_planA purchase plan name, publisher, and product for the image, for use in a community gallery or marketplace images.
galleryImagerecommended_configurationRecommended range of vCPUs and memory for VMs created from this image.
galleryImagerecommended_memoryA recommended range of memory for VMs created from this image. Default is 1 Gb to 32 Gb.
igalleryImagemagerecommended_vcpuA recommended range of vCPUs for VMs created from this image. The default is 1 to 16.
galleryImagerelease_notes_uriURI where release notes can be found for the image.
galleryImageadd_tagsAdd tags to the image resource.
galleryImagedepends_onAdd explicit dependencies for the image resource.
galleryAppnameName of the gallery application.
galleryAppgalleryGallery where the application is distributed.
galleryAppdescriptionDescription of the gallery application.
galleryAppos_typeOperating system required by the gallery application (Windows or Linux).
galleryAppadd_tagsAdd tags to the gallery application resource.
galleryAppdepends_onAdd explicit dependencies for the gallery application resource.
galleryAppVersionnameName of the gallery application.
galleryAppVersiongallery_appGallery Application for the Version.
galleryAppVersiongalleryGallery where the application version is distributed.
galleryAppVersionend_of_lifeDate when the Gallery Application Version is not longer supported.
galleryAppVersioninstall_actionShell script to execute to install the the application version.
galleryAppVersionremove_actionShell script to execute to remove the the application version.
galleryAppVersionsource_media_linkA storage account link (public or SAS URL) for media to include.
galleryAppVersionadd_target_regionsAdds regions where the gallery application version should be distributed for VM installation.
galleryAppVersionadd_tagsAdd tags to the gallery application version resource.
galleryAppVersiondepends_onAdd explicit dependencies for the gallery application version resource.
open Farmer
open Farmer.Arm.Gallery
open Farmer.Builders

let myGallery =
    gallery {
        name "mygallery"
        description "Example Community Image Gallery"
        sharing_profile (
            Community {
                Eula = "End User License Agreement goes here"
                PublicNamePrefix = "farmages"
                PublisherContact = "farmer.gallery@example.com"
                PublisherUri = System.Uri "https://compositionalit.github.io/farmer"
            }
        )
    }

let myImage =
    galleryImage {
        name "my-server-image"
        gallery myGallery

        gallery_image_identifier (
            {
                Offer = "my-server"
                Publisher = "farmages"
                Sku = "my-server-2023"
            }
        )

        hyperv_generation Image.HyperVGeneration.V2
        os_state Image.OsState.Generalized
        os_type OS.Linux
    }

arm {
    add_resources [
        myGallery
        myImage
    ]
}
open Farmer
open Farmer.Arm.Gallery
open Farmer.Builders

let myGallery =
    gallery {
        name "mygallery"
        description "Example Community Image Gallery"
        sharing_profile (
            Community {
                Eula = "End User License Agreement goes here"
                PublicNamePrefix = "farmages"
                PublisherContact = "farmer.gallery@example.com"
                PublisherUri = System.Uri "https://compositionalit.github.io/farmer"
            }
        )
    }

let myGalleryApp =
    galleryApp {
        name "java-app.tar.gz"
        gallery myGallery
        os_type OS.Linux
    }

let myGalleryAppVersion = galleryAppVersion {
    name "1.0.1"
    gallery_app myGalleryApp
    gallery myGallery
    end_of_life (DateTimeOffset(DateTime(2026, 9, 30)))
    install_action "sudo apt-get update && sudo apt-get -y install openjdk-17-jre-headless"
    remove_action "sudo apt-get remove openjdk-17-jre-headless && sudo apt-get autoremove"
    source_media_link "https://mystorageaccount/sas-url"

    add_target_regions [
        targetRegion { name Location.EastUS }
        targetRegion { name Location.EastUS2 }
        targetRegion { name Location.WestUS2 }
        targetRegion { name Location.WestUS3 }
        targetRegion { name Location.NorthEurope }
        targetRegion { name Location.WestEurope }
    ]
}

arm {
    add_resources [
        myGallery
        myGalleryApp
        myGalleryAppVerion
    ]
}