Azion CLI deploy
Azion CLI command that builds a project and deploys it to Azion, remotely or with a local build, with every flag, its type, and its default.
The Azion CLI deploy command builds the project in the current directory and deploys it to Azion. It creates or updates the project’s Application, its Workload, and, for a static site, the Object Storage bucket that holds the files. By default the build runs on Azion; with --local, it runs on your machine. The options every command accepts, such as --format, --out, and -y, are on Global options.
Usage
azion deploy reads the project settings from the azion folder of the current directory and deploys the project:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--alias-env | — | — | — | Passes --alias-env to the build phase of the deploy, so the variables read from the project’s .env files get a prefix built from the project’s name. For more information, refer to Azion CLI build. |
--auto | — | — | — | Runs the whole command without stopping for a question. |
--config-dir | — | string | "azion" | Relative path to the folder that holds your azion.json and args.json files. |
--config-file | — | string | — | Path to the azion.config file to deploy with, such as azion.staging.config.cjs. Without it, the deploy uses the azion.config.* file in the current directory. In a remote deploy, the default, the file must be inside the project directory, because only that directory is uploaded. With --local, the deploy writes the storage prefix into this file and builds from it. A missing file, or a file outside the project in a remote deploy, is rejected before the deploy changes anything on your machine or on Azion. |
--dry-run | — | — | — | Lists the steps the deploy would run, without running them. The dry run creates and changes no resource and leaves azion/azion.json untouched, and --format json prints the list as JSON. The steps are those of the --local flow, also when you run azion deploy --dry-run without --local. |
--env | — | string | ".edge/.env" | Relative path to your .env file. |
--local | — | — | — | Runs the build and the deploy on your machine instead of on Azion. Use it when you need your own build environment or more control over the build. |
--no-prompt | — | — | — | Returns the error instead of asking a question when a step fails. |
--path | — | string | — | Path to the folder that holds your static files. |
--skip-build | — | — | — | Deploys without running the build first. |
--skip-framework-build | — | — | — | Skips the framework build that runs before azion build. |
--sync | — | — | — | Synchronizes the local azion.json file with the remote resources. |
--workers | — | int | auto-calculated based on CPU cores, max 20 | Number of upload workers that send files at the same time. |
--writable-bucket | — | — | — | Creates the project bucket with read-write access. |
The CLI manages the storage credentials each route needs, so no upload asks you for one. A default deploy uploads the source files for the remote build, with the credentials in ~/.azion/<profile>/settings.toml. With --local, the CLI uploads the built static files itself and keeps one credential set per bucket in ~/.azion/<profile>/credentials.toml.
Examples
Each example shows the command and the output it prints.
Deploy with a remote build
This command deploys a static site for the first time. The CLI uploads the source files, and the build runs on Azion:
The command prints a link to the Deploy page of Azion Console, where Deploy Log shows the progress of the deploy, and then the domain of the site:
The first deploy can take several minutes to answer from every location; later deploys take about two minutes.
The command writes the ID of every resource it creates into azion/azion.json. The next deploy reads these IDs and updates the same resources instead of creating new ones:
The first deploy also writes an empty azion/args.json. A project whose azion.config declares a function and no static files deploys the function alone. Its azion.json then has an empty bucket and null for connectors and cache-settings. It carries a function entry with the id of the function and the instance-id of its function instance. A project that declares both carries both sets of IDs.
Deploy with a local build
This command deploys a change to the same site. The CLI builds the project on your machine, uploads the files, and updates each resource by the ID in azion/azion.json:
The command runs the build itself, whether or not an earlier azion build left a .edge folder. Only --skip-build and --skip-framework-build stop it. Before the build, it writes a new storage prefix into azion.config.cjs, or into azion.config.mjs when the project has both files:
A later deploy takes about two minutes to answer from every location.
Preview a deploy
This command simulates a local deploy of the same site:
The command exits without changing any resource, and azion/azion.json keeps the same content.