Skip to content

Commit 27a618f

Browse files
committed
Initial commit
0 parents  commit 27a618f

19 files changed

+548
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Update Azure SQL database
2+
3+
#Sets the trigger to update when update is pushed to main branch
4+
on:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
11+
# Job to build and publish the dacpac
12+
build:
13+
# Easier to use Github-hosted runner if updating in GitHub
14+
runs-on: windows-latest
15+
16+
# Steps represent a sequence of tasks that will be executed as part of the job
17+
steps:
18+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
19+
- uses: actions/checkout@v2.3.4
20+
# Find msbuild
21+
- name: Add msbuild to PATH
22+
uses: microsoft/setup-msbuild@v1.0.3
23+
# create dacpac using MSBUILD
24+
- name: Build Database project
25+
run: |
26+
msbuild.exe AzureSQLDB.sqlproj /p:Configuration=Release
27+
# Publish artifact
28+
- uses: actions/upload-artifact@v2.2.4
29+
with:
30+
name: AzureSQLDB
31+
path: ${{ github.workspace }}/bin/Release/
32+
33+
# Deploy dacpac job
34+
DeployAzureSQLDB:
35+
# Set the dependency for the build job
36+
needs: build
37+
# Easier to use Github-hosted runner if updating in GitHub
38+
runs-on: windows-latest
39+
40+
# Steps to deploy the updates to Azure SQL Database
41+
# To keep this example simple, the Firewall settings in the logical SQL Server allows access from Azure services and resources
42+
# An alternative is to use the Azure Login GitHub Action https://github.com/marketplace/actions/azure-login
43+
steps:
44+
- name: download artifact containing dacpac
45+
# Dowloads Data artifact to dacpac folder
46+
uses: actions/download-artifact@v2.0.10
47+
with:
48+
name: AzureSQLDB
49+
# Installs dacpac
50+
# For this to work you MUST have two secrets specified, defaults in my repo are blank
51+
# One called AZURESQLDB_SERVER which contains your logical SQL Server name
52+
# Another called AZURESQLDB_CONNECTION_STRING which contains connection string to your Azure SQL Database
53+
- name: Azure SQL Deploy
54+
uses: Azure/sql-action@v1
55+
with:
56+
# The logical SQL Server name
57+
server-name: '${{ secrets.AZURESQLDB_SERVER }}'
58+
# The connection string, including authentication information, for the Azure SQL Database.
59+
connection-string: '${{ secrets.AZURESQLDB_CONNECTION_STRING }}'
60+
# Name of the dacpac file in the artifact
61+
dacpac-package: 'AzureSQLDB.dacpac'

AzureSQLDB.sqlproj

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<Name>AzureSQLDB</Name>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectVersion>4.1</ProjectVersion>
9+
<ProjectGuid>{A082F44F-0299-477F-B11A-A5168DAC6C4E}</ProjectGuid>
10+
<DSP>Microsoft.Data.Tools.Schema.Sql.SqlAzureV12DatabaseSchemaProvider</DSP>
11+
<OutputType>Database</OutputType>
12+
<RootPath>
13+
</RootPath>
14+
<RootNamespace>AzureSQLDB</RootNamespace>
15+
<AssemblyName>AzureSQLDB</AssemblyName>
16+
<ModelCollation>1033, CI</ModelCollation>
17+
<DefaultFileStructure>BySchemaAndSchemaType</DefaultFileStructure>
18+
<DeployToDatabase>True</DeployToDatabase>
19+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
20+
<TargetLanguage>CS</TargetLanguage>
21+
<AppDesignerFolder>Properties</AppDesignerFolder>
22+
<SqlServerVerification>False</SqlServerVerification>
23+
<IncludeCompositeObjects>True</IncludeCompositeObjects>
24+
<TargetDatabaseSet>True</TargetDatabaseSet>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<OutputPath>bin\Release\</OutputPath>
28+
<BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName>
29+
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
30+
<DebugType>pdbonly</DebugType>
31+
<Optimize>true</Optimize>
32+
<DefineDebug>false</DefineDebug>
33+
<DefineTrace>true</DefineTrace>
34+
<ErrorReport>prompt</ErrorReport>
35+
<WarningLevel>4</WarningLevel>
36+
</PropertyGroup>
37+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
38+
<OutputPath>bin\Debug\</OutputPath>
39+
<BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName>
40+
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
41+
<DebugSymbols>true</DebugSymbols>
42+
<DebugType>full</DebugType>
43+
<Optimize>false</Optimize>
44+
<DefineDebug>true</DefineDebug>
45+
<DefineTrace>true</DefineTrace>
46+
<ErrorReport>prompt</ErrorReport>
47+
<WarningLevel>4</WarningLevel>
48+
</PropertyGroup>
49+
<PropertyGroup>
50+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">11.0</VisualStudioVersion>
51+
<!-- Default to the v11.0 targets path if the targets file for the current VS version is not found -->
52+
<SSDTExists Condition="Exists('$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets')">True</SSDTExists>
53+
<VisualStudioVersion Condition="'$(SSDTExists)' == ''">11.0</VisualStudioVersion>
54+
</PropertyGroup>
55+
<Import Condition="'$(NetCoreBuild)' == 'true'" Project="$(NETCoreTargetsPath)\Microsoft.Data.Tools.Schema.SqlTasks.targets" />
56+
<Import Condition="'$(NetCoreBuild)' != 'true' AND '$(SQLDBExtensionsRefPath)' != ''" Project="$(SQLDBExtensionsRefPath)\Microsoft.Data.Tools.Schema.SqlTasks.targets" />
57+
<Import Condition="'$(NetCoreBuild)' != 'true' AND '$(SQLDBExtensionsRefPath)' == ''" Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" />
58+
<ItemGroup>
59+
<PackageReference Condition="'$(NetCoreBuild)' == 'true'" Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
60+
</ItemGroup>
61+
<ItemGroup>
62+
<Folder Include="Properties" />
63+
<Folder Include="Security" />
64+
<Folder Include="dbo" />
65+
<Folder Include="dbo\Tables" />
66+
</ItemGroup>
67+
<Target Name="BeforeBuild">
68+
<Delete Files="$(BaseIntermediateOutputPath)\project.assets.json" />
69+
</Target>
70+
<ItemGroup>
71+
<Build Include="dbo\Tables\Tablec.sql" />
72+
<Build Include="dbo\Tables\Tableb.sql" />
73+
<Build Include="dbo\Tables\Tablea.sql" />
74+
</ItemGroup>
75+
</Project>

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Database Project for Azure SQL Database
2+
3+
Example of a SQL Server Database Project that deploys to an Azure SQL Database using GitHub Actions.
4+
5+
It uses a YAML pipeline, which is in the /.github/workflows folder.
6+
7+
In order to use it in GitHub Actions you can either import or fork this repository into another GitHub repository.
8+
9+
In order for the workflow to run the firewall settings for the logical SQL Server MUST allow Azure services and resources to access the server. Alternatively, add the Azure Login GitHub Action to this workflow https://github.com/marketplace/actions/azure-login.
10+
11+
In addition, you MUST have two secrets specified, defaults in my repo are blank:
12+
13+
- AZURESQLDB_SERVER, which contains your logical SQL Server name
14+
- AZURESQLDB_CONNECTION_STRING, which contains connection string to your Azure SQL Database
15+
16+
This repository is provided "as is" based on the MIT license (https://opensource.org/licenses/MIT). Basically, I am not responsible for your use of it.
2.52 KB
Binary file not shown.
3.5 KB
Binary file not shown.
9.5 KB
Binary file not shown.

dbo/Tables/Tablea.sql

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CREATE TABLE [dbo].[Tablea] (
2+
[col1] INT NOT NULL,
3+
[colc] VARCHAR (10) NULL
4+
)
5+
6+
7+
8+
GO
9+
10+
11+
12+
GO
13+

dbo/Tables/Tableb.sql

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CREATE TABLE [dbo].[Tableb] (
2+
[col1] INT NOT NULL,
3+
[col2] VARCHAR (10) NULL
4+
)
5+
6+
7+
8+
GO
9+
10+
11+
12+
GO
13+

dbo/Tables/Tablec.sql

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CREATE TABLE [dbo].[Tablec] (
2+
[col1] INT NOT NULL,
3+
[col2] VARCHAR (10) NULL
4+
)
5+
6+
GO
7+
8+
9+
10+
GO
11+

debug.log

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[0524/201306.396:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"format": 1,
3+
"restore": {
4+
"c:\\repos\\Create dacpac from ADS test\\Create dacpac from ADS test.sqlproj": {}
5+
},
6+
"projects": {
7+
"c:\\repos\\Create dacpac from ADS test\\Create dacpac from ADS test.sqlproj": {
8+
"version": "1.0.0",
9+
"restore": {
10+
"projectUniqueName": "c:\\repos\\Create dacpac from ADS test\\Create dacpac from ADS test.sqlproj",
11+
"projectName": "Create dacpac from ADS test",
12+
"projectPath": "c:\\repos\\Create dacpac from ADS test\\Create dacpac from ADS test.sqlproj",
13+
"packagesPath": "C:\\Users\\kchan\\.nuget\\packages\\",
14+
"outputPath": "c:\\repos\\Create dacpac from ADS test\\obj\\",
15+
"projectStyle": "PackageReference",
16+
"skipContentFileWrite": true,
17+
"configFilePaths": [
18+
"C:\\Users\\kchan\\AppData\\Roaming\\NuGet\\NuGet.Config",
19+
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
20+
],
21+
"originalTargetFrameworks": [
22+
"net46"
23+
],
24+
"sources": {
25+
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
26+
"https://api.nuget.org/v3/index.json": {}
27+
},
28+
"frameworks": {
29+
"net46": {
30+
"projectReferences": {}
31+
}
32+
}
33+
},
34+
"frameworks": {
35+
"net46": {
36+
"dependencies": {
37+
"Microsoft.NETFramework.ReferenceAssemblies": {
38+
"suppressParent": "All",
39+
"target": "Package",
40+
"version": "[1.0.0, )"
41+
}
42+
}
43+
}
44+
}
45+
}
46+
}
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8" standalone="no"?>
2+
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
4+
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
5+
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
6+
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
7+
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
8+
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\kchan\.nuget\packages\</NuGetPackageFolders>
9+
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
10+
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.8.0</NuGetToolVersion>
11+
</PropertyGroup>
12+
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
13+
<SourceRoot Include="$([MSBuild]::EnsureTrailingSlash($(NuGetPackageFolders)))" />
14+
</ItemGroup>
15+
<PropertyGroup>
16+
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
17+
</PropertyGroup>
18+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8" standalone="no"?>
2+
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
5+
</PropertyGroup>
6+
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
7+
<Import Project="$(NuGetPackageRoot)microsoft.netframework.referenceassemblies.net46\1.0.0\build\Microsoft.NETFramework.ReferenceAssemblies.net46.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.netframework.referenceassemblies.net46\1.0.0\build\Microsoft.NETFramework.ReferenceAssemblies.net46.targets')" />
8+
</ImportGroup>
9+
</Project>
3.5 KB
Binary file not shown.
9.5 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
c:\repos\Create dacpac from ADS test\bin\Debug\Create dacpac from ADS test.dacpac
2+
c:\repos\Create dacpac from ADS test\bin\Debug\Create dacpac from ADS test.dll
3+
c:\repos\Create dacpac from ADS test\bin\Debug\Create dacpac from ADS test.pdb
4+
c:\repos\Create dacpac from ADS test\obj\Debug\Create dacpac from ADS test.sqlprojAssemblyReference.cache
5+
c:\repos\Create dacpac from ADS test\obj\Debug\Model.xml
6+
c:\repos\Create dacpac from ADS test\obj\Debug\refactor.xml
7+
c:\repos\Create dacpac from ADS test\obj\Debug\postdeploy.sql
8+
c:\repos\Create dacpac from ADS test\obj\Debug\predeploy.sql
9+
c:\repos\Create dacpac from ADS test\obj\Debug\Create dacpac from ADS test.dll
10+
c:\repos\Create dacpac from ADS test\obj\Debug\Create dacpac from ADS test.pdb
Binary file not shown.

0 commit comments

Comments
 (0)