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

# Azure Container Apps

export const Alert = ({type, title, children}) => {
  const getIcon = () => {
    switch (type) {
      case 'info':
        return "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M10 0C4.477 0 0 4.477 0 10s4.477 10 10 10 10-4.477 10-10S15.523 0 10 0zm0 15c-.552 0-1-.448-1-1s.448-1 1-1 1 .448 1 1-.448 1-1 1zm1-3H9V6h2v6z' fill='%230099FF'/%3E%3C/svg%3E";
      case 'success':
        return "data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M10 0C4.477 0 0 4.477 0 10s4.477 10 10 10 10-4.477 10-10S15.523 0 10 0zm4.293 6.293L9 11.586 5.707 8.293c-.391-.391-1.024-.391-1.414 0s-.391 1.024 0 1.414l4 4c.391.391 1.024.391 1.414 0l6-6c.391-.391.391-1.024 0-1.414s-1.024-.391-1.414 0z' fill='%230CC26D'/%3E%3C/svg%3E";
      case 'warning':
        return "data:image/svg+xml;charset=utf-8;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHhtbDpzcGFjZT0ncHJlc2VydmUnIHdpZHRoPScxMDgwJyBoZWlnaHQ9JzEwODAnPjxyZWN0IHdpZHRoPScxMDAlJyBoZWlnaHQ9JzEwMCUnIGZpbGw9J3RyYW5zcGFyZW50Jy8+PHBhdGggZD0nTTEzLjc5NCAxMC43NSA4LjMgMS4yNWExLjUgMS41IDAgMCAwLTIuNiAwbC01LjQ5NCA5LjVBMS40OTQgMS40OTQgMCAwIDAgMS41IDEzaDExYTEuNDkzIDEuNDkzIDAgMCAwIDEuMjk0LTIuMjVNNi41IDUuNWEuNS41IDAgMCAxIDEgMFY4YS41LjUgMCAwIDEtMSAwek03IDExYS43NS43NSAwIDEgMSAwLTEuNS43NS43NSAwIDAgMSAwIDEuNScgc3R5bGU9J3N0cm9rZTpub25lO3N0cm9rZS13aWR0aDoxO3N0cm9rZS1kYXNoYXJyYXk6bm9uZTtzdHJva2UtbGluZWNhcDpidXR0O3N0cm9rZS1kYXNob2Zmc2V0OjA7c3Ryb2tlLWxpbmVqb2luOm1pdGVyO3N0cm9rZS1taXRlcmxpbWl0OjQ7ZmlsbDojZmY5ZjM1O2ZpbGwtcnVsZTpub256ZXJvO29wYWNpdHk6MScgdHJhbnNmb3JtPSd0cmFuc2xhdGUoLjAyIDE5LjMwNSlzY2FsZSg3Ny4xNCknLz48L3N2Zz4=";
      case 'danger':
        return "data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M10 0C4.477 0 0 4.477 0 10s4.477 10 10 10 10-4.477 10-10S15.523 0 10 0zm5.707 4.293L10 9.586 4.293 4.293c-.391-.391-1.024-.391-1.414 0s-.391 1.024 0 1.414L8.586 11l-5.707 5.293c-.391.391-.391 1.024 0 1.414s1.024.391 1.414 0L10 12.414l5.707 5.293c.391.391 1.024.391 1.414 0s.391-1.024 0-1.414L11.414 11l5.707-5.293c.391-.391.391-1.024 0-1.414s-1.024-.391-1.414 0z' fill='%23F45252'/%3E%3C/svg%3E";
      case 'note':
        return "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M10 0C4.477 0 0 4.477 0 10s4.477 10 10 10 10-4.477 10-10S15.523 0 10 0zm0 15c-.552 0-1-.448-1-1s.448-1 1-1 1 .448 1 1-.448 1-1 1zm1-3H9V6h2v6z' fill='%230099FF'/%3E%3C/svg%3E";
      default:
        return "";
    }
  };
  return <div className={`alert alert--${type}`}>
      <div className="alert-icon" style={{
    backgroundImage: `url("${getIcon()}")`,
    backgroundRepeat: 'no-repeat',
    backgroundPosition: 'center center',
    backgroundSize: '20px',
    width: '24px',
    height: '24px',
    position: 'absolute',
    left: '16px',
    top: '16px'
  }} />
      <div className="alert-content">
        {title && <div className="alert-title">{title}</div>}
        <div className="alert-body">{children}</div>
      </div>
    </div>;
};

This guide walks you through deploying the Superblocks data plane on **Azure Container Apps** using either the **Azure Portal**, the **Azure CLI** or a **YAML File**.

## Prerequisites

* Azure subscription with permissions to create resources
* Superblocks Agent Key ([generate one](https://app.superblocks.com/access-tokens))
* [Install Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-macos) (See [quickstart](https://learn.microsoft.com/en-us/azure/container-apps/get-started?tabs=bash) for example usage)

## Deploy resources

### Create Subnet

If your agent needs to talk to internal APIs and databases inside a specific Azure VNet, create a new subnet inside that VNet. The subnet should be dedicated to the Azure Container Apps Environment with no other resources.

<Tabs groupId="deployment_method">
  <Tab title="Azure Portal">
    Navigate to your VNet then choose **Settings** -> **Subnets** -> **+ Subnet**. Configure the subnet settings, including setting **Subnet Delegation** to "Microsoft.App/environments".
  </Tab>

  <Tab title="Azure CLI">
    Run the following command to create a new subnet delegated to container app environments.

    ```bash theme={null}
    az network vnet subnet create \
      --resource-group MyResourceGroup \
      --vnet-name MyVnet \
      --name MySubnet \
      --address-prefixes 10.0.0.0/24 \
      --delegations Microsoft.App/environments
    ```
  </Tab>
</Tabs>

### Create Container Apps Environment

<Tabs groupId="deployment_method">
  <Tab title="Azure Portal">
    1. Navigate to **Container Apps** -> **+ Create** -> **Container App**
    2. Under **Container Apps environment**, click the link to **Create new environment**
    3. Configure **Networking** to enable or disable **Public Network Access** and specify the **Virtual network** using the VNet / subnet created in the [previous section](#create-subnet).
  </Tab>

  <Tab title="Azure CLI">
    Run the following command, using `--infrastructure-subnet-resource-id` to specify the Subnet ID for the subnet created in the [previous section](#create-subnet).

    ```bash theme={null}
    az containerapp env create \
      --name MyContainerappEnvironment \
      --resource-group MyResourceGroup \
      --location eastus \
      --infrastructure-subnet-resource-id SUBNET_ID
    ```
  </Tab>
</Tabs>

For more information on public vs. private endpoints, see [Networking in Azure Container Apps environment](https://learn.microsoft.com/en-us/azure/container-apps/networking?tabs=workload-profiles-env%2Cazure-cli).

### Create Container App

<Tabs groupId="deployment_method">
  <Tab title="Azure Portal">
    1. Go to **Container Apps** → **+ Create**
    2. Under **Basics** tab, specify the subscription, resource group, app name, and container apps environment (see [Create container apps environment](#create-container-apps-environment))
    3. Under **Container** tab:

       **Container details**

           <Alert type="info">
             These are the required container image settings if using the Superblocks hosted image. Update these accordingly if you host your own custom image.
           </Alert>

       * Image source: Select **Docker Hub or other registries**
       * Image type: Select **Public**
       * Registry login server: `ghcr.io`
       * Image: `superblocksteam/agent:latest`

       **Container resource allocation**

       * Set 2 CPU, 4.0 GiB memory

       **Environment variables**

       * Add `SUPERBLOCKS_AGENT_DATA_DOMAIN = app.superblocks.com`
       * Add `SUPERBLOCKS_ORCHESTRATOR_AGENT_HOST_URL = https:<container_app_name>.<defaultDomain>`
       * Add `SUPERBLOCKS_ORCHESTRATOR_AGENT_TAGS = profile:*`
    4. Under **Ingress** tab:
       * Enable ingress, configure **Ingress traffic** settings, and set **Target port** to 8080
    5. Click **Create**

    When creating the container app through the Azure Portal, there are a few additional configuration steps required after the container app is created. Navigate to the container app resource and complete the following:

    * Under **Application** -> **Scale**, set **Min Replicas** to 1. To adjust horizontal scaling, optionally configure **Max replicas**.
    * Under **Security** -> **Secrets**, create a secret to store the Superblocks agent key, using either a Container Apps Secret or Key Vault reference.
    * Under **Application** -> **Containers**, select the **Environment variables** tab and set both `SUPERBLOCKS_AGENT_KEY` and `SUPERBLOCKS_ORCHESTRATOR_SUPERBLOCKS_KEY` to the previously created secret reference. Click **Save as a new revision**.
  </Tab>

  <Tab title="Azure CLI">
    First, install the required extensions and providers:

    ```bash theme={null}
    az extension add --name containerapp --upgrade
    az provider register --namespace Microsoft.App
    az provider register --namespace Microsoft.OperationalInsights
    ```

    ```bash theme={null}
    APP_NAME="superblocks-agent"
    AGENT_KEY="<YOUR_GENERATED_AGENT_KEY>"
    AGENT_URL="<AZURE_APPLICATION_URL>"

    az containerapp create \
      --name $APP_NAME \
      --resource-group myresourcegroup \
      --environment superblocks-env \
      --image superblocksteam/agent:latest \
      --cpu 2.0 --memory 4.0Gi \
      --ingress external --target-port 8080 \
      --secrets agent-key=$AGENT_KEY \
      --env-vars SUPERBLOCKS_AGENT_KEY=secretref:agent-key \
                 SUPERBLOCKS_ORCHESTRATOR_SUPERBLOCKS_KEY=secretref:agent-key \
                 SUPERBLOCKS_AGENT_DATA_DOMAIN="app.superblocks.com" \
                 SUPERBLOCKS_ORCHESTRATOR_AGENT_HOST_URL=$AGENT_URL \
                 SUPERBLOCKS_ORCHESTRATOR_AGENT_TAGS="profile:*" \
      --min-replicas 1 --max-replicas 1
    ```

    **Note:** If using a private registry, provide full image path and configure credentials accordingly.
  </Tab>

  <Tab title="YAML Template">
    You can deploy the Superblocks data plane on Azure Container Apps by creating a `.yaml` file and passing it to the `az containerapp create` command.

    ```yaml theme={null}
    properties:
      environmentId: "/subscriptions/<subscription_id>/resourceGroups/<resource_group_name>/providers/Microsoft.App/managedEnvironments/<environment_name>"
      configuration:
        ingress:
          external: <true/false>
          allowInsecure: <true/false>
          targetPort: 8080
        secrets:
          - name: "agent-key"
            value: "<agent_key_value>"
      template:
        containers:
          - image: ghcr.io/superblocksteam/agent:latest
            name: <container_app_name>
            resources:
              cpu: 2.0
              memory: 4.0Gi
            env:
              - name: "SUPERBLOCKS_ORCHESTRATOR_SUPERBLOCKS_KEY"
                secretRef: "agent-key"
              - name: "SUPERBLOCKS_AGENT_KEY"
                secretRef: "agent-key"
              - name: "SUPERBLOCKS_AGENT_DATA_DOMAIN"
                value: "app.superblocks.com"
              - name: "SUPERBLOCKS_ORCHESTRATOR_AGENT_HOST_URL"
                value: "https:<container_app_name>.<defaultDomain>"
              - name: "SUPERBLOCKS_ORCHESTRATOR_AGENT_TAGS"
                value: "profile:*"
        scale:
          minReplicas: 1
          maxReplicas: 1
    ```

    Run:

    ```bash theme={null}
    az containerapp create -n ContainerAppName -g MyResourceGroup --environment MyContainerAppEnv --yaml "path/to/yaml/file.yml"
    ```
  </Tab>
</Tabs>

## Verify agent is running

Check the application status:

```bash theme={null}
az containerapp show \
  --name superblocks-agent \
  --resource-group myresourcegroup \
  --query properties.configuration.ingress.fqdn -o tsv
```

View application logs:

```bash theme={null}
az containerapp logs show \
  --name my-container-app \ 
  --resource-group my-container-apps
```

Visit the [data plane page](https://app.superblocks.com/opas) in Superblocks to confirm the service appears as **Active**.

## Billable services

The Superblocks data plane may make use of the following Azure services. Be aware of the pricing associated with these.

* [Azure Container Apps](https://azure.microsoft.com/en-us/pricing/details/container-apps/) - Serverless container platform with consumption-based pricing (includes free monthly grants of 180,000 vCPU-seconds, 360,000 GiB-seconds, and 2M requests)
* [Azure Monitor & Log Analytics](https://azure.microsoft.com/en-us/pricing/details/monitor/) - Logging and monitoring solution for diagnostics (optional)
* [Azure Key Vault](https://azure.microsoft.com/en-us/pricing/details/key-vault/) - Secure secret storage for credentials and configuration (optional)
* [Virtual Network](https://azure.microsoft.com/en-us/pricing/details/virtual-network/) - Network infrastructure for private deployments (optional)
