Skip to content

Quickstart: Install the ESAF tools

In this quickstart, you install one ESAF tool, start the Factory API and check that they connect. The Factory API is the one service that every tool calls. It ships inside the app, so you don't install it separately.

Tip

Run it guided. The ESAF Tutorial Guide types each command for you and checks every step: it also starts its own Factory API. Open an ESAF tutorial and the track Scenarios 1-3. Download the ESAF Tutorial Guide. It's a private preview: ask Joakim Åström on LinkedIn for a preview code.

Diagram that shows the app, CLI, Python SDK and REST as clients of the same Factory API.

Every tool is an L1 client of the same Factory API, so the result is the same whichever you pick. See the onion architecture.

Prerequisites

  • Windows x64: Git for Windows, which includes Git Bash. For the CLI (PowerShell) tab, also PowerShell 7.3 or later.
  • Linux or macOS: Git and Bash. Use the CLI (bash), Python SDK or REST tab. The one-call scenarios need the app package v0.47.100 or later. Check the download table: a Linux or macOS package older than that starts the API, but it doesn't have the one-call scenarios yet.
  • Azure CLI and Python 3.10 or later.
  • A Git repository for your Factory's configuration, in GitHub or Azure DevOps. This is your consumer repository.

Start the Factory API

Option A) Windows - Start via ESAF Tutorial Guide (Windows app only) 1. Download the [ESAF Tutorial Guide](https://github.com/jostrm/azure-enterprise-scale-ml/blob/main/environment_setup/install_tutorial_guide/README.md) 2. From within the app, click "Start API". Wait until the pill shows **Running** with a port number. ![ESAF Tutorial Guide](../assets/repository/documentation/v2/20-29/images/esaf-tutorial-app-start-api.png) 3. The **API started** dialog shows the auto-generated API key. Select **Copy key** if you need it in another tool, then **Close**. The guide's API uses a new port every time it starts, so you don't type the address or the key yourself: under [Connect your tool](#connect-your-tool), the guide's **Type connection** button types both into PowerShell for you, in one line. Keep the guide open. The API stops when you close it.
Option B) Mac & Linux - Start via ESAF Wizard App (Windows, Mac OS, Linux) The Factory API ships inside the **AIFactory Config Wizard**, a desktop app for Windows, Linux and macOS. 1. Download the [AIFactory Config Wizard](https://github.com/jostrm/azure-enterprise-scale-ml/blob/main/environment_setup/install_config_wizard/readme.md#download) for your system. 2. Extract the archive. On Windows, keep the `_internal` folder beside `aifactory-config.exe`. 3. Open the app. On Windows, that's `aifactory-config.exe`. For the other systems, see [macOS](https://github.com/jostrm/azure-enterprise-scale-ml/blob/main/environment_setup/install_config_wizard/readme.md#macos) and [Linux](https://github.com/jostrm/azure-enterprise-scale-ml/blob/main/environment_setup/install_config_wizard/readme.md#linux). 4. In the left menu, select **Quick setup**, then **Start API host**. Do this before you open any other window in the app, so that you choose the key. ![ESAF Tutorial Guide](../assets/repository/documentation/v2/20-29/images/esaf-wizard-tkinter-start-api.png) 5. In the **API Host Authentication** dialog, enter a private API key. You choose it. remember it for the next steps. 6. Copy the API address from the **API Host Started** dialog. The default is `http://127.0.0.1:8765`. The status bar shows it too. Keep the app open. The API stops when you close it.
Option C) Windows - Start from the command line (no app window) The Windows package of the AIFactory Config Wizard also runs the Factory API on its own, without a window. You need v0.47.107 or later. Run these lines in the PowerShell window you use for the next steps. 1. Download and extract the package:
Invoke-WebRequest 'https://github.com/jostrm/azure-enterprise-scale-ml/raw/refs/heads/main/environment_setup/install_config_wizard/windows/aifactory-config-windows.zip' -OutFile "$HOME\Downloads\aifactory-config-windows.zip"
Expand-Archive "$HOME\Downloads\aifactory-config-windows.zip" "$HOME\aifactory-config" -Force
2. Start the API with a new random key. The key stays in `$env:AIFACTORY_API_KEY` in this window; it is never shown:
$env:AIFACTORY_API_KEY = [Convert]::ToBase64String([Security.Cryptography.RandomNumberGenerator]::GetBytes(32))
$api = Start-Process "$HOME\aifactory-config\aifactory-config\aifactory-config.exe" -ArgumentList '--api-host', '--port', '8765' -PassThru
foreach ($i in 1..30) { try { Invoke-RestMethod http://127.0.0.1:8765/health; break } catch { Start-Sleep 1 } }
The API answers on `http://127.0.0.1:8765` and only on this computer. Keep this PowerShell window open: it holds the key. To stop the API, run `Stop-Process -Id $api.Id`.

Create your Factory folder

Your Factory's configuration lives in an azurefactory folder in your consumer repository.

  1. Open Bash in the root of your consumer repository. On Windows, that's Git Bash.
  2. Add this repository as a submodule and create the folder:
git submodule add -b release/v1.25 https://github.com/jostrm/azure-enterprise-scale-ml
bash ./azure-enterprise-scale-ml/01-start-v125-and-above.sh

Expected output, among other lines:

Initialized empty register: C:\work\team-factory\azurefactory\register.json

The script creates azurefactory\register.json with no factories in it. It changes nothing in Azure. See folder structure.

Connect your tool

Choose one tool. You can add the others later; they all use the same API address, key and folder.

The App tabs use Enterprise Scale AI Factory, the ESAF desktop app for Windows 11. It starts its own Factory API, so you can skip "Start the Factory API" above.

  1. Install the app from its download folder. You need version 1.0.24 or later.
  2. Open Enterprise Scale AI Factory from Start.
  3. On Start Guide, under Consumer repository root, select Browse repository and pick your consumer repository.

Open PowerShell in the root of your consumer repository.

  1. Install the CLI:
python -m pip install .\azure-enterprise-scale-ml\environment_setup\azurefactory-cli
  1. Connect to the Factory API:
  2. Option A, ESAF Tutorial Guide: in the guide, select Type connection, then click this PowerShell window within 3 seconds. The guide types one line that sets $env:AIFACTORY_API_URL and $env:AIFACTORY_API_KEY for its API. Press Enter. The line includes the key, so don't share a screenshot of it.
  3. Option B, AIFactory Config Wizard:

    $env:AIFACTORY_API_URL = 'http://127.0.0.1:8765'
    $env:AIFACTORY_API_KEY = Read-Host 'API key you entered in the app'
    
  4. Option C, command line: run the next lines in the same PowerShell window that started the API. The key is already set there; set only the address:

    $env:AIFACTORY_API_URL = 'http://127.0.0.1:8765'
    
  5. Point the CLI at your folder and check the connection:

$env:ESAF_FOLDER = (Resolve-Path .\azurefactory).Path
azurefactory health

Open Bash in the root of your consumer repository. With the ESAF Tutorial Guide (option A), use the port that its pill shows (Running ... on port N) instead of 8765, and paste the key from its Copy key button.

python3 -m pip install ./azure-enterprise-scale-ml/environment_setup/azurefactory-cli
export AIFACTORY_API_URL='http://127.0.0.1:8765'
read -r -s -p 'API key you entered in the app: ' AIFACTORY_API_KEY && export AIFACTORY_API_KEY
export ESAF_FOLDER="$PWD/azurefactory"
azurefactory health

In Git Bash on Windows, the API needs a Windows path: export ESAF_FOLDER="$(cygpath -w "$PWD/azurefactory")".

Install the SDK and set the connection once. This is PowerShell; on Linux or macOS, use the three export lines from the CLI (bash) tab instead. With the ESAF Tutorial Guide (option A), select Type connection in the guide and click this PowerShell window instead of the Read-Host line: it also sets the API address.

python -m pip install .\azure-enterprise-scale-ml\environment_setup\azurefactory-cli
$env:AIFACTORY_API_KEY = Read-Host 'API key you entered in the app'
$env:ESAF_FOLDER = (Resolve-Path .\azurefactory).Path

Then save this as check_connection.py and run it:

from azurefactory import esaf

session = esaf.connect()  # reads ESAF_FOLDER, AIFACTORY_API_URL and AIFACTORY_API_KEY
catalog = session.client.catalog_list(session.folder)
print([factory["key"] for factory in catalog["factories"]])

Open Bash (on Windows: Git Bash). Health needs no key:

curl --silent --show-error --fail-with-body http://127.0.0.1:8765/health

List the scenario routes that the API serves:

curl --silent --show-error http://127.0.0.1:8765/openapi.json \
  | grep -o '"/api/v1/esaf/[^"]*"' | sort -u

Every other request needs your key in the X-API-Key header.

Verify the result

Your tool reaches the API, and your folder holds no factory yet.

Tool Expected output
App The status light at the bottom shows API connected.
CLI, in either shell azurefactory health prints "status": "ok".
Python SDK The script prints [].
REST The second command lists seven routes that start with /api/v1/esaf/.

For example, the CLI prints:

{
  "status": "ok",
  "version": "1.0.0"
}

If something goes wrong:

Message Fix
AIFACTORY_API_KEY is required, or HTTP 401 Set the key again. It must match the key you entered in the app.
The Factory API has no /api/v1/esaf routes Your app package is older than v0.47.100. Download the current package. On Linux and macOS, check the download table for a package with that version.
Select an absolute local factory folder without traversal. Set ESAF_FOLDER with Resolve-Path, as shown.
ModuleNotFoundError: azurefactory Run the pip install line again with the same python.

Next step

Back: Setup docs

Next: Quickstart: Create your AI Factory

Related: