> ## Documentation Index
> Fetch the complete documentation index at: https://anaconda.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# AppDeployer.deploy

```python theme={null}
AppDeployer.deploy(
    readiness_condition: str = 'at_least_one_running',
    max_wait_time: int = 600,
    readiness_wait_time: int = 60,
    logger_fn: Callable = print,
    **kwargs
)
```

Deploys the app to Anaconda Platform. This method packages and deploys the configured app, waiting for it to reach the specified readiness condition before returning.

**Parameters:**

<ParamField path="readiness_condition" type="string" default="at_least_one_running">
  The condition that must be met for the deployment to be considered ready.

  Deployment readiness conditions define what counts as a successful completion of the current deployment instance. They exist because deployments often run from CI/CD environments, where downstream build triggers depend on a specific completion criterion, and because different users need different guarantees: some want a cluster of workers ready before serving traffic, while others want just one worker ready.

  Available readiness conditions:

  * `at_least_one_running`: At least `min(min_replicas, 1)` workers of the current deployment instance's version have started running. Use when endpoints are deployed ephemerally and are considered ready when at least one instance is running; additional instances are for load management.
  * `all_running`: At least `min_replicas` workers are running for the deployment to be considered ready. Use when inference endpoints are under an SLA or need to handle a larger load.
  * `fully_finished`: At least `min_replicas` workers are running, and no pending or crashlooping workers from previous versions remain. Use to ensure the endpoint is fully available and no other versions are running, or that the endpoint has been fully scaled down.
  * `async`: The deployment is considered ready as soon as the server acknowledges it has registered the app in the backend. Use when you only care that the URL is minted, or when the deployment should eventually scale to zero.
</ParamField>

<ParamField path="max_wait_time" type="integer" default="600">
  Maximum time in seconds to wait for the deployment to reach readiness.
</ParamField>

<ParamField path="readiness_wait_time" type="integer" default="60">
  Once the deployment meets `readiness_condition`, workers are monitored for an additional `readiness_wait_time` seconds to catch crash loops that surface shortly after startup. If a worker enters a crash loop during this window, the deploy fails with `AppCrashLoopException`. Increase this value for apps with slow startups or when infrastructure is not quickly available.
</ParamField>

<ParamField path="logger_fn" type="function">
  Function to use for logging progress messages. Default prints to stderr.
</ParamField>

**Returns:**

<ResponseField name="value" type="DeployedApp">
  An object representing the deployed app with methods to interact with it (`logs`, `info`, `scale_to_zero`, `delete`) and properties like `public_url`.
</ResponseField>

**Raises:**

* `CodePackagingException`: If `code_package` is not provided or is not a valid `PackagedCode` instance.
* `AppConfigError`: If the app configuration is invalid.
* `AppCreationFailedException`: If the app deployment submission fails due to an API error. Contains `status_code` and `error_text` attributes for debugging.
* `AppCrashLoopException`: If a worker enters a CrashLoopBackOff or Failed state during deployment. Contains `worker_id` and `logs` attributes for debugging.
* `AppReadinessException`: If the app fails to meet readiness conditions within `max_wait_time`.
* `AppUpgradeInProgressException`: If an upgrade is already in progress when deployment starts. Use `force_upgrade=True` to override. Contains the `upgrader` attribute.
* `AppConcurrentUpgradeException`: If another deployment was triggered while this deployment was in progress, invalidating the current deployment. Contains `expected_version` and `actual_version`.
* `OuterboundsBackendUnhealthyException`: If the platform backend is unreachable (network issues, DNS failures) or returns server errors (HTTP 5xx). This indicates a platform-side issue, not a problem with your configuration. Retry the deployment or contact Anaconda support.
* `AppDeletedDuringDeploymentException`: If the app was deleted by another process or user while this deployment was in progress. This can occur when concurrent operations conflict.

**Examples:**

**Basic deployment:**

```python expandable theme={null}
from metaflow.apps import bake_image, package_code, AppDeployer
baked = bake_image(pypi={"flask": ">=2.0"})
pkg = package_code(src_paths=["./src"])
deployer = AppDeployer(
    name="my-app",
    port=8000,
    image=baked.image,
    code_package=pkg,
    commands=["python server.py"],
)
deployed = deployer.deploy()
print(deployed.public_url)
```

**Wait for all replicas to be ready:**

```python theme={null}
deployed = deployer.deploy(
    readiness_condition="all_running"
)
```

**Async deployment (don't wait for workers):**

```python theme={null}
deployed = deployer.deploy(
    readiness_condition="async"
)
```

**Handling deployment errors:**

```python expandable theme={null}
from metaflow.apps import AppDeployer
from metaflow.apps.exceptions import (
    AppReadinessException,
)

try:
    deployed = deployer.deploy()
except AppReadinessException as e:
    print(f"App {e.app_id} failed to become ready in time but we can move forward")
    deployed_app:DeployedApp = e.deployed_app
    # use DeployedApp to do whatever you need
```
