# Azion CLI sync

The Azion CLI `sync` command synchronizes the local configuration file of a project, `azion/azion.json`, with the resources the project has on Azion. With `--iac`, it also writes an `azion.config` file that describes those resources as code. The options every command accepts, such as `--format`, `--out`, and `-y`, are on [Global options](/en/documentation/devtools/cli/globals/).

---

## Usage

Run `azion sync` in the folder of a project that has an `azion` folder:

```bash
azion sync [flags]
```

| Flag           | Short | Type   | Default        | Description                                                                            |
| -------------- | ----- | ------ | -------------- | -------------------------------------------------------------------------------------- |
| `--config-dir` | —     | string | `"azion"`      | Relative path to the folder that holds your `azion.json` and `args.json` files.        |
| `--env`        | —     | string | `".edge/.env"` | Relative path to your `.env` file.                                                     |
| `--extension`  | —     | string | `"mjs"`        | Extension of the `azion.config` file that `--iac` writes: `mjs`, `cjs`, `ts`, or `js`. |
| `--iac`        | —     | —      | —              | Also writes an `azion.config` file that describes the resources of the project.        |

Variables in the `.env` file whose names contain `password`, `pwd`, `secret`, `key`, `hash`, `encrypted`, `passcode`, `auth`, or `token` are sent to Azion as secrets.

---

## Examples

Each example shows the command and the output it prints.

### Synchronize a project

This command synchronizes a static site that was deployed with `azion deploy`:

```bash
azion sync
```

The command prints one line for each stage:

```text
Reading manifest.json file
Synched successfully
```

For a site that has not changed since `azion deploy`, `azion/azion.json` keeps the same content.

### Write the configuration as code

This command synchronizes the same site and writes its configuration to an `azion.config` file:

```bash
azion sync --iac
```

The command prints the name of the file it wrote:

```text
Reading manifest.json file
…
[Azion] [IaC] › ✔  success   Config file generated successfully at azion.config.mjs
Synched successfully
```

The file `azion.config.mjs` holds the build settings of the site and its resources: the storage bucket, the application with its cache settings and rules, the connector, and the workload. `azion/azion.json` keeps the same content.

When the project already has an `azion.config.cjs` file, the command writes `azion.config.mjs` next to it. The next `azion deploy --local` then writes the storage prefix into the `.mjs` file.

---

## Related resources

- [Global options](/en/documentation/devtools/cli/globals.md): The options every command accepts, such as `--debug`, `--format`, and `-y`.
- [Azion CLI deploy](/en/documentation/devtools/cli/deploy.md): The command that creates the resources of a project and writes their IDs into `azion/azion.json`.
- [azion.config.js](/en/documentation/devtools/cli/azion-config-js.md): What each section of the `azion.config` file that `--iac` writes configures.
- [Azion CLI link](/en/documentation/devtools/cli/link-command.md): How an existing project gets the `azion` folder that the command reads.
