PreviewKit User Guide

Comprehensive reference for configuration and advanced features

New to PreviewKit? Start with the Getting Started Guide for a 5-minute setup walkthrough.

This guide covers authentication options, configuration reference, advanced use cases, and troubleshooting.


Table of Contents


Prerequisites

Azure Resources Required

ResourcePurpose
Resource GroupContainer for all preview resources
Container Apps EnvironmentShared environment for all previews
Container Registry (ACR)Stores your Docker images
App RegistrationOIDC authentication from GitHub

GitHub Requirements

RequirementPurpose
DockerfileYour app must be containerized
Repository secretsAzure authentication credentials
Repository variablesAzure resource configuration

Azure Setup

For detailed Azure infrastructure setup instructions, see the Getting Started guide.

Once you have your Azure resources configured, choose an authentication method below.


Authentication Options

PreviewKit supports two authentication methods for pulling images from ACR. Choose based on your security requirements:

Option 1: User-Assigned Managed Identity (Recommended)

Best for: Production environments, security-conscious teams

Advantages:

  • ✅ No passwords to manage
  • ✅ Automatic credential rotation
  • ✅ Azure-native security
  • ✅ Works for new container apps

Setup:

bash
# Create identity
az identity create --name previewkit-acr-pull --resource-group $RESOURCE_GROUP

# Grant AcrPull permission
IDENTITY_PRINCIPAL=$(az identity show --name previewkit-acr-pull --resource-group $RESOURCE_GROUP --query principalId -o tsv)
ACR_ID=$(az acr show --name $ACR_NAME --query id -o tsv)
az role assignment create --assignee $IDENTITY_PRINCIPAL --role AcrPull --scope $ACR_ID

Workflow usage:

yaml
- uses: krav4enkodm/previewkit/action@main
  with:
    azure-registry-server: yourregistry.azurecr.io
    azure-registry-identity: /subscriptions/.../userAssignedIdentities/previewkit-acr-pull

Option 2: Admin Credentials

Best for: Quick setup, testing, simple deployments

Advantages:

  • ✅ Simple to configure
  • ✅ No identity management required
  • ✅ Works immediately

Disadvantages:

  • ⚠️ Shared credentials (not per-app)
  • ⚠️ Password rotation is manual
  • ⚠️ Less secure for production

Setup:

bash
# Enable ACR admin
az acr update --name $ACR_NAME --admin-enabled true

# Get credentials
az acr credential show --name $ACR_NAME

Add to GitHub Secrets:

  • AZURE_REGISTRY_USERNAME: ACR admin username
  • AZURE_REGISTRY_PASSWORD: ACR admin password

Workflow usage:

yaml
- uses: krav4enkodm/previewkit/action@main
  with:
    azure-registry-server: yourregistry.azurecr.io
    azure-registry-username: ${{ secrets.AZURE_REGISTRY_USERNAME }}
    azure-registry-password: ${{ secrets.AZURE_REGISTRY_PASSWORD }}

Workflow Configuration

For a complete workflow example, see Getting Started - Step 3.

Below are the key configuration options and advanced use cases.


Action Inputs Reference

Required Inputs

InputDescriptionExample
service-nameName of your servicemy-frontend
portContainer port to expose3000

Cloud Configuration

InputDescriptionDefault
cloudCloud providerazure

Azure-Specific Inputs

InputDescriptionRequired
azure-subscription-idAzure subscription IDYes
azure-resource-groupResource group nameYes
azure-locationAzure regionNo (default: eastus)
azure-container-app-environmentContainer Apps Environment nameYes
azure-registry-serverACR server URLIf using private images
azure-registry-identityUser-assigned identity IDOption 1
azure-registry-usernameACR admin usernameOption 2
azure-registry-passwordACR admin passwordOption 2

Container Settings

InputDescriptionDefault
imageContainer image to deploy<service-name>:<sha>

Optional Settings

InputDescription
github-tokenGitHub token for PR comments

Action Outputs

OutputDescription
preview-urlURL of the deployed preview
preview-idUnique identifier of the preview

Usage in workflow:

yaml
- name: Deploy Preview
  id: preview
  uses: krav4enkodm/previewkit/action@main
  with:
    # ... inputs

- name: Use preview URL
  run: echo "Preview deployed at ${{ steps.preview.outputs.preview-url }}"

Advanced Configuration

Custom Environment Variables

Pass environment variables to your container by configuring them in the Container App directly or through your Dockerfile.

Multiple Services

For multiple services in the same repo, create separate workflows:

yaml
# .github/workflows/preview-frontend.yml
- uses: krav4enkodm/previewkit/action@main
  with:
    service-name: frontend
    port: 3000

# .github/workflows/preview-backend.yml
- uses: krav4enkodm/previewkit/action@main
  with:
    service-name: backend
    port: 8080

Preview Naming

Preview environments are named deterministically:

text
<service-name>-pr-<number>-<sha-prefix>

Example: my-frontend-pr-42-a1b2c3d

This ensures:

  • Unique names per PR
  • No collisions between services
  • Easy identification in Azure portal

Troubleshooting

Common Issues

"Environment not found"

Cause: Container Apps Environment doesn't exist or wrong name

Fix:

bash
# List available environments
az containerapp env list --resource-group $RESOURCE_GROUP --query "[].name" -o tsv

"Failed to pull image" / ACR authentication error

Cause: Missing or incorrect ACR credentials

Fix:

  1. If using managed identity, verify role assignment:
    bash
    az role assignment list --assignee $IDENTITY_PRINCIPAL --scope $ACR_ID
    
  2. If using admin credentials, verify they're correct:
    bash
    az acr credential show --name $ACR_NAME
    

"OIDC authentication failed"

Cause: Federated credential not configured for pull requests

Fix:

bash
# Check existing credentials
az ad app federated-credential list --id $APP_OBJECT_ID

# Create credential for pull_request
az ad app federated-credential create \
    --id $APP_OBJECT_ID \
    --parameters '{
        "name": "github-pr",
        "issuer": "https://token.actions.githubusercontent.com",
        "subject": "repo:YOUR_ORG/YOUR_REPO:pull_request",
        "audiences": ["api://AzureADTokenExchange"]
    }'

"Identity operation failed" / Location mismatch

Cause: Stale managed identity from previous failed deployment

Fix:

bash
# Delete stale identity
az identity delete --name <identity-name> --resource-group $RESOURCE_GROUP

# Delete stale container app
az containerapp delete --name <app-name> --resource-group $RESOURCE_GROUP --yes

Debug Mode

For detailed logs, check the GitHub Actions logs:

  1. Go to Actions tab in your repository
  2. Click on the failed run
  3. Expand the "Deploy Preview" step

Support


What's Next

  • Just getting started? See the Getting Started Guide for a complete setup walkthrough
  • Roadmap: PreviewKit is actively developed with upcoming features including AWS App Runner, GCP Cloud Run, preview dashboard, and cost visibility