Skip to content

Robertjam954/multimodal_rag_application / .claude/skills/azure-deploy

azure-deploy

Flagged

Execute Azure deployments for ALREADY-PREPARED applications that have existing .azure/deployment-plan.md and infrastructure files. DO NOT use this skill when the user asks to CREATE a new application — use azure-prepare instead. This skill runs azd up, azd deploy, terraform apply, and az deployment commands with built-in error recovery. Requires .azure/deployment-plan.md from azure-prepare and validated status from azure-validate. WHEN: "run azd up", "run azd deploy", "execute deployment", "push to production", "push to cloud", "go live", "ship it", "bicep deploy", "terraform apply", "publish to Azure", "launch on Azure". DO NOT USE WHEN: "create and deploy", "build and deploy", "create a new app", "set up infrastructure", "create and deploy to Azure using Terraform" — use azure-prepare for these.

FileKindSize
SKILL.mdskill md6.5 KB
references/auth-best-practices.mdmarkdown6.1 KB
references/global-rules.mdmarkdown1.2 KB
references/live-role-verification.mdmarkdown3.9 KB
references/pre-deploy-checklist.mdmarkdown18.4 KB
references/recipes/README.mdmarkdown431 B
references/recipes/azcli/README.mdmarkdown1.7 KB
references/recipes/azcli/errors.mdmarkdown492 B
references/recipes/azcli/verify.mdmarkdown2.0 KB
references/recipes/azd/README.mdmarkdown3.7 KB
references/recipes/azd/ef-migrations.mdmarkdown5.0 KB
references/recipes/azd/errors.mdmarkdown15.4 KB
references/recipes/azd/functions-deploy.mdmarkdown3.5 KB
references/recipes/azd/post-deployment.mdmarkdown4.2 KB
references/recipes/azd/scripts/apply-migrations.ps1script1.8 KB
references/recipes/azd/scripts/apply-migrations.shscript1.8 KB
references/recipes/azd/scripts/grant-and-migrate.ps1script4.2 KB
references/recipes/azd/scripts/grant-and-migrate.shscript4.3 KB
references/recipes/azd/sql-entra-auth.mdmarkdown2.5 KB
references/recipes/azd/sql-managed-identity.mdmarkdown7.4 KB
references/recipes/azd/verify.mdmarkdown4.9 KB
references/recipes/bicep/README.mdmarkdown2.4 KB
references/recipes/bicep/errors.mdmarkdown511 B
references/recipes/bicep/verify.mdmarkdown763 B
references/recipes/cicd/README.mdmarkdown1.2 KB
references/recipes/cicd/errors.mdmarkdown542 B
references/recipes/cicd/examples/azdo-azd.ymlconfig487 B
references/recipes/cicd/examples/azdo-multistage.ymlconfig831 B
references/recipes/cicd/examples/github-azd.ymlconfig782 B
references/recipes/cicd/examples/github-bicep.ymlconfig660 B
references/recipes/cicd/verify.mdmarkdown754 B
references/recipes/terraform/README.mdmarkdown3.2 KB
references/recipes/terraform/errors.mdmarkdown858 B
references/recipes/terraform/verify.mdmarkdown752 B
references/region-availability.mdmarkdown3.0 KB
references/sdk/azd-deployment.mdmarkdown792 B
references/sdk/azure-identity-dotnet.mdmarkdown941 B
references/sdk/azure-identity-java.mdmarkdown1.2 KB
references/sdk/azure-identity-py.mdmarkdown1.1 KB
references/sdk/azure-identity-ts.mdmarkdown1.1 KB
references/troubleshooting.mdmarkdown8.0 KB

references/recipes/azd/ef-migrations.md

View on GitHub
# EF Core Migrations Deployment

Apply Entity Framework Core migrations to Azure SQL Database after deployment.

## Detection

EF Core projects contain `Migrations/` folder or `Microsoft.EntityFrameworkCore` package reference in `.csproj`.

```bash
find . -type d -name "Migrations" 2>/dev/null
find . -name "*.csproj" -exec grep -l "Microsoft.EntityFrameworkCore" {} \;
```

**PowerShell:**
```powershell
Get-ChildItem -Recurse -Directory -Filter "Migrations" -ErrorAction SilentlyContinue
Get-ChildItem -Recurse -Filter "*.csproj" | Select-String -List "Microsoft.EntityFrameworkCore" | Select-Object -ExpandProperty Path
```

## Deployment Methods

### Method 1: azd Hook (Recommended)

Automate via `postprovision` hook in `azure.yaml`:

```yaml
hooks:
  postprovision:
    posix:
      shell: sh
      run: ./scripts/apply-migrations.sh
    windows:
      shell: pwsh
      run: ./scripts/apply-migrations.ps1
```

**Copy the pre-built scripts** — Read [scripts/apply-migrations.sh](scripts/apply-migrations.sh) and [scripts/apply-migrations.ps1](scripts/apply-migrations.ps1) and write them verbatim to the project's `scripts/` folder. Adjust `APP_PROJECT_PATH` / `$AppProjectPath` in the script to the location of the `.csproj` directory.

Key behaviours of the scripts:
- Loads `azd env get-values` safely (no `eval`)
- Installs `dotnet-ef` automatically when not present; no-op when already installed
- Fails on genuine install errors (network failure, missing SDK)
- Adds `~/.dotnet/tools` to `PATH` so the tool is immediately available

> 💡 Make executable: `chmod +x scripts/*.sh`.

### Method 2: SQL Script (Production)

Generate idempotent script for review before applying:

> ⚠️ **Warning:** `az sql db query` requires the `rdbms-connect` extension: `az extension add --name rdbms-connect --yes`

```bash
dotnet ef migrations script --idempotent --output migrations.sql
az sql db query --server "$SQL_SERVER" --database "$SQL_DATABASE" \
  --auth-mode ActiveDirectoryDefault --queries "$(cat migrations.sql)"
```

**PowerShell:**
```powershell
dotnet ef migrations script --idempotent --output migrations.sql
$MigrationsSql = Get-Content migrations.sql -Raw
az sql db query --server $env:SQL_SERVER --database $env:SQL_DATABASE `
  --auth-mode ActiveDirectoryDefault --queries $MigrationsSql
```

### Method 3: Application Startup (Dev Only)

⚠️ **Development only** — production should use explicit migration steps.

```csharp
// Program.cs
if (app.Environment.IsDevelopment()) {
    using var scope = app.Services.CreateScope();
    scope.ServiceProvider.GetRequiredService<ApplicationDbContext>().Database.Migrate();
}
```

## Combined Hook: SQL Access + Migrations

Combine both steps in a single `postprovision` hook using the pre-built combined scripts:

```yaml
hooks:
  postprovision:
    posix:
      shell: sh
      run: ./scripts/grant-and-migrate.sh
    windows:
      shell: pwsh
      run: ./scripts/grant-and-migrate.ps1
```

**Copy the pre-built scripts** — Read [scripts/grant-and-migrate.sh](scripts/grant-and-migrate.sh) and [scripts/grant-and-migrate.ps1](scripts/grant-and-migrate.ps1) and write them verbatim to the project's `scripts/` folder. Adjust `APP_PROJECT_PATH` / `$AppProjectPath` in the script to the location of the `.csproj` directory.

> 💡 Make executable: `chmod +x scripts/*.sh`

## Prerequisites

Install EF Core tools:

```bash
dotnet tool install --global dotnet-ef
dotnet ef --version  # Verify installation
```

## Connection String

```
Server=tcp:{server}.database.windows.net,1433;Database={database};Authentication=Active Directory Default;Encrypt=True;
```

## Troubleshooting

| Error | Solution |
|-------|----------|
| Cannot open database | Check firewall rules: `az sql server firewall-rule list` |
| Login failed | Grant SQL access per [sql-managed-identity.md](sql-managed-identity.md) |
| Unable to create DbContext | Add `IDesignTimeDbContextFactory` implementation |
| Hook fails but deployment continues | Remove `|| true` to make migrations block deployment |

**DbContext Factory Example:**

```csharp
public class ApplicationDbContextFactory : IDesignTimeDbContextFactory<ApplicationDbContext> {
    public ApplicationDbContext CreateDbContext(string[] args) {
        var optionsBuilder = new DbContextOptionsBuilder<ApplicationDbContext>();
        var connectionString = Environment.GetEnvironmentVariable("CONNECTION_STRING") 
            ?? args.FirstOrDefault() ?? "Server=(localdb)\\mssqllocaldb;Database=MyDb;Trusted_Connection=True;";
        optionsBuilder.UseSqlServer(connectionString);
        return new ApplicationDbContext(optionsBuilder.Options);
    }
}
```

## Best Practices

- Use `--idempotent` flag for production scripts
- Version control Migrations/ folder
- Test locally before deploying
- Backup production databases before applying
- Keep migrations small and focused

## References

- [SQL Managed Identity Access](sql-managed-identity.md)
- [Post-Deployment Guide](post-deployment.md)
- [EF Core Migrations](https://learn.microsoft.com/ef/core/managing-schemas/migrations/)
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 322kUpdated Claude CodeCodexVerifiedInstall
xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release.Stars: 118kUpdated Claude CodeCodexVerifiedInstall