# Azion CLI deploy

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](/en/documentation/platform/applications/), its [Workload](/en/documentation/platform/workloads/), and, for a static site, the [Object Storage](/en/documentation/platform/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](/en/documentation/devtools/cli/globals/).

---

## Usage

`azion deploy` reads the project settings from the `azion` folder of the current directory and deploys the project:

```bash
azion deploy [flags]
```

| 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](/en/documentation/devtools/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:

```bash
azion deploy
```

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:

```text
Running deploy command
Uploading source files

Upload completed successfully!
Please visit https://console.azion.com/create/deploy/00000000-0000-0000-0000-000000000002 in case it did not open automatically, to follow up the full deploy process
Your Application was deployed successfully

To visualize your application access the Domain: https://xxxxxxxxxx.map.azionedge.net
Your application is being deployed to all Azion Locations and it might take a few minutes.
```

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:

```json
{
  "name": "my-site",
  "bucket": "my-site",
  "preset": "html",
  "env": "production",
  "prefix": "20260101120000",
  "rotate-prefix": true,
  "not-first-run": true,
  "function": [],
  "application": {
    "id": 1234567892,
    "name": "my-site"
  },
  "domain": {
    "id": 0,
    "name": "__DEFAULT__",
    "domain_name": "",
    "url": ""
  },
  "rt-purge": {
    "purge_on_publish": true
  },
  "origin": null,
  "rules-engine": {
    "created": false,
    "rules": [
      {
        "id": 123458,
        "name": "Deliver Static Assets and Set Cache Policy",
        "phase": "request"
      },
      {
        "id": 123459,
        "name": "Redirect to index.html",
        "phase": "request"
      },
      {
        "id": 123460,
        "name": "Redirect to index.html for Subpaths",
        "phase": "request"
      }
    ]
  },
  "cache-settings": [
    {
      "id": 123468,
      "name": "my-site"
    }
  ],
  "workloads": {
    "id": 1234567902,
    "name": "my-site",
    "domains": [],
    "url": "https://xxxxxxxxxx.map.azionedge.net",
    "deployment_id": [
      {
        "id": 123472,
        "name": "my-site"
      }
    ]
  },
  "connectors": [
    {
      "id": 123476,
      "name": "my-site"
    }
  ]
}
```

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`:

```bash
azion deploy --local
```

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:

```text
Running deploy command
…
[Azion] › ℹ  info      Successfully replaced "20260101120000" with "20260101120100" (2 occurrences) in azion.config.cjs

Building your Application. This process may take a few minutes
Running build step command:

$ npx --yes  @aziontech/bundler@1.2.0 build --preset html --config-version 4
…
[Azion] [Build] › ℹ  info      Using preset: html
[Azion] [Pre-Build] › ℹ  info      Starting pre-build...
[Azion] [Pre-Build] › ℹ  info      Pre-build completed successfully
[Azion] [Build] › ℹ  info      Using built-in handler from "html" preset.
[Azion] [Build] › ℹ  info      Starting build...
[Azion] [Build] › ✔  success   Build completed successfully
[Azion] [Post-Build] › ℹ  info      Starting post-build...
[Azion] [Post-Build] › ✔  success   Post-build completed successfully
[Azion] [Storage] › ℹ  info      Using provided prefix for storage 'my-site': 20260101120100
[Azion] [IaC] › ✔  success   Manifest generated successfully at <project-dir>/.edge/manifest.json
Your Application was built successfully
Updated Application my-site with ID 1234567892
Reading manifest.json file
Reading manifest.json file
Uploading source files

Uploading files  50% |████████████████████                    | (1/2) [0s:0s]

Upload completed successfully!
Edge Application my-site with id 1234567892 successfully updated
Cache Setting my-site with id 123468 successfully updated
Connector my-site with id 123476 successfully updated
Rule Engine Deliver Static Assets and Set Cache Policy with id 123458 successfully updated
Rule Engine Redirect to index.html with id 123459 successfully updated
Rule Engine Redirect to index.html for Subpaths with id 123460 successfully updated
Rules Engine of Application with id 1234567892 successfully ordered (request phase)
Workload my-site with id 1234567902 successfully updated
Workload Deployment my-site with id 123472 successfully updated
Your Application was deployed successfully

To visualize your application access the Domain: https://xxxxxxxxxx.map.azionedge.net
Your application is being deployed to all Azion Edge Locations and it might take a few minutes.
```

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:

```bash
azion deploy --local --dry-run
```

The command exits without changing any resource, and `azion/azion.json` keeps the same content.

---

## Related resources

- [Global options](/en/documentation/devtools/cli/globals.md): The options every command accepts, such as `--debug`, `--format`, and `-y`.
- [Azion CLI build](/en/documentation/devtools/cli/build.md): The command that builds the project, which `--skip-build` leaves out of the deploy.
- [Azion CLI link](/en/documentation/devtools/cli/link-command.md): How an existing project gets the `azion` folder that the deploy reads.
- [Azion CLI rollback](/en/documentation/devtools/cli/rollback.md): How to serve the static files of a previous deploy again.
