Skip to content

Commit cff848d

Browse files
committed
Update
1 parent c70ee1f commit cff848d

File tree

10 files changed

+35
-35
lines changed

10 files changed

+35
-35
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
pull_request:
66

77
jobs:
8-
test:
8+
ci:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v4

.github/workflows/deploy.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,17 @@ on:
77
workflow_dispatch:
88
inputs:
99
environment:
10+
type: choice
1011
description: 'Environment'
1112
required: true
1213
default: 'dev'
1314
options:
14-
dev:
15-
- 'dev'
16-
staging:
17-
- 'staging'
18-
prod:
19-
- 'prod'
15+
- 'dev'
16+
- 'staging'
17+
- 'prod'
2018

2119
jobs:
22-
build:
20+
deploy:
2321
runs-on: ubuntu-latest
2422
environment:
2523
name: ${{ github.event.inputs.environment }}

DbProject/dbo/Tables/DimCustomer.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,3 @@ CREATE TABLE [dbo].[DimCustomer] (
1313

1414

1515
GO
16-

DbProject/dbo/Tables/DimDate.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ CREATE TABLE [dbo].[DimDate] (
1111

1212

1313
GO
14-

DbProject/dbo/Tables/DimProduct.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@ CREATE TABLE [dbo].[DimProduct] (
99

1010

1111
GO
12-

DbProject/dbo/Views/vSalesByRegion.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,3 @@
1414
GROUP BY d.[Year], d.[Month], d.MonthName, c.CountryRegion;
1515

1616
GO
17-

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11

2-
.PHONY: all docker clean
2+
.PHONY: docker build clean
33

4-
all:
4+
docker:
5+
docker compose up --build --force-recreate --remove-orphans -d
6+
7+
build:
58
dotnet tool restore
69
dotnet outdated --upgrade
710
dotnet build
811

9-
docker:
10-
docker compose up --build --force-recreate --remove-orphans -d
11-
1212
clean:
1313
dotnet clean
1414
docker compose down --remove-orphans --volumes

README.md

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,41 @@
55

66
## Overview
77

8-
> This project demonstrates how to automate database development with
9-
[dacpac](https://learn.microsoft.com/en-us/sql/relational-databases/data-tier-applications/data-tier-applications?view=sql-server-ver16)
10-
to an Azure SQL Database using a GitHub Actions.
8+
> This project demonstrates how to automate database development with 'microsoft.sqlpackage' to an Azure SQL Database using a GitHub Actions.
119
1210

13-
## Flow
11+
## Flow
1412

15-
1. Database Project build
16-
2. DacPack file is created
17-
3. Contents of dacpac is consumed by Github Action
18-
4. Deploy against a database
13+
1. Build SQL server objects (tables, views, and instance objects)
14+
2. Dacpack file is created
15+
3. Contents of dacpac is consumed by Github Actions
16+
4. Deploy against a SQL database
1917

2018

2119
## Prerequisites
2220
- Azure Subscription
2321

2422
## Setup
2523
1. Create a new Azure Service Principal
26-
2. Create a new Azure SQL Database, see infra [README.md](../infra/README.md) for more details.
24+
2. Create a new Azure SQL Database, see infra [Makefile](./infra/Makefile) for more details.
2725

2826
## Configuration
2927
1. Add the following secrets to your GitHub repository:
30-
- `AZURE_SQL_CONNECTION_STRING` - Azure SQL Database connection string
28+
- `AZURE_SQL_CONNECTION_STRING` - Azure SQL Database connection string of your choice
3129

3230
## Azure Deployment
33-
See [deploy.yml](.github/workflows/deploy.yml)
31+
1. Run database deployment from github actions tab. See [deploy.yml](.github/workflows/deploy.yml)
3432

3533

36-
## Resources
37-
- https://github.com/microsoft/DacFx?tab=readme-ov-file#-create-a-sql-project
38-
- https://learn.microsoft.com/en-gb/sql/tools/sqlpackage/sqlpackage?view=sql-server-ver16
39-
- https://learn.microsoft.com/en-us/sql/relational-databases/data-tier-applications/data-tier-applications?view=sql-server-ver16
40-
- https://www.nuget.org/packages/microsoft.build.sql/
34+
## Local development environment
35+
To run sql project in Docker, follow these steps:
36+
37+
1. Build and start the necessary containers
38+
```bash
39+
make docker
40+
```
41+
42+
2. Examine the logs
43+
```bash
44+
docker compose logs -f sqlpackage
45+
```

compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ services:
88
env_file:
99
- .env
1010
environment:
11+
DACFX_TELEMETRY_OPTOUT: true
1112
SourceFile: "bin/Debug/DbProject.dacpac"
1213
TargetConnectionString: "Server=tcp:db,1433;Initial Catalog=demo;UID=sa;Password=${MSSQL_SA_PASSWORD};TrustServerCertificate=true;Connection Timeout=3;"
1314
volumes:
@@ -18,7 +19,7 @@ services:
1819
- -c
1920
- |
2021
/scripts/deploy.sh
21-
# enables to keep the container running
22+
# keep the container running (for debugging)
2223
tail -f /dev/null
2324
depends_on:
2425
db:

tests/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# select all tables and views from sql server:
33

44
QUERY="
5-
SELECT * FROM INFORMATION_SCHEMA.TABLES
5+
SELECT * FROM INFORMATION_SCHEMA.TABLES
66
"
77

88
docker exec -it --env-file .env db /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$MSSQL_SA_PASSWORD" -Q "$QUERY" -b

0 commit comments

Comments
 (0)