diff --git a/CI/AKS/docker/Dockerfile.ssis.mssql2017 b/CI/AKS/docker/Dockerfile.ssis.mssql2017 new file mode 100644 index 000000000..8100721e5 --- /dev/null +++ b/CI/AKS/docker/Dockerfile.ssis.mssql2017 @@ -0,0 +1,44 @@ +# Adapted from: https://github.com/Microsoft/mssql-docker/blob/master/windows/mssql-server-windows-developer/dockerfile +# +# +FROM mcr.microsoft.com/windows/servercore:ltsc2019 +LABEL maintainer "Liz B & Sebastian M" + +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Continue'; $ProgressPreference = 'SilentlyContinue';"] + +WORKDIR / + +# MSSQL 2017 Download links +ENV exe "https://go.microsoft.com/fwlink/?linkid=840945" +ENV box "https://go.microsoft.com/fwlink/?linkid=840944" +ENV ACCEPT_EULA="Y" + +COPY ssis_scripts/* SSIS_SCRIPTS/ + +# Install MSSQL 2017 +RUN mode CON: CP /status ; \ + CHCP ; \ + CHCP 437 ; \ + Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Nls\CodePage" | Select-Object OEMCP, ACP ; \ + Invoke-WebRequest -Uri $env:box -OutFile SQL.box ; \ + Invoke-WebRequest -Uri $env:exe -OutFile SQL.exe ; \ + Start-Process -Wait -FilePath .\SQL.exe -ArgumentList /qs, /x:setup ; \ + .\setup\setup.exe /q /ACTION=Install /INSTANCENAME=MSSQLSERVER /FEATURES=SQLEngine,IS /UPDATEENABLED=0 /SQLSVCACCOUNT='NT AUTHORITY\System' /SQLSYSADMINACCOUNTS='BUILTIN\ADMINISTRATORS' /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS ; \ + Remove-Item -Recurse -Force SQL.exe, SQL.box, setup ; \ + mkdir SSIS_TMP ; \ + Get-Service MSSQLSERVER ; + +RUN .\SSIS_SCRIPTS\setupSSIS + +RUN Get-Service MSSQLSERVER ; \ + Stop-Service MSSQLSERVER ; \ + Set-ItemProperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.MSSQLSERVER\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpdynamicports -value '' ; \ + Set-ItemProperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.MSSQLSERVER\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpport -value 1433 ; \ + Set-ItemProperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.MSSQLSERVER\mssqlserver\' -name LoginMode -value 2 ; +HEALTHCHECK CMD [ "sqlcmd", "-Q", "select 1" ] + +COPY start.ps1 / +RUN net user /add LOCAL_SQLSRVR +RUN powershell -Command Add-LocalGroupMember -Group "Administrators" -Member "LOCAL_SQLSRVR" +USER LOCAL_SQLSRVR +CMD .\start -ACCEPT_EULA $env:ACCEPT_EULA -sqlsrvrlogin "LOCAL_SQLSRVR" -Verbose *> start_script.log diff --git a/CI/AKS/docker/ssis_scripts/createSSISCatalog.ps1 b/CI/AKS/docker/ssis_scripts/createSSISCatalog.ps1 new file mode 100644 index 000000000..ac4427168 --- /dev/null +++ b/CI/AKS/docker/ssis_scripts/createSSISCatalog.ps1 @@ -0,0 +1,26 @@ +# from https://github.com/teach-for-america/ssiscicd/blob/master/docker/mssqlssis/create_ssis_catalog.ps1 +# script to create ssis catalog and deploy ssis ispac file + +# Load the IntegrationServices Assembly +[Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Management.IntegrationServices") + +# Store the IntegrationServices Assembly namespace to avoid typing it every time +$ISNamespace = "Microsoft.SqlServer.Management.IntegrationServices" + +Write-Host "Connecting to server ..." + +# Create a connection to the server +$sqlConnectionString = "Data Source=localhost;Initial Catalog=master;Integrated Security=SSPI;" +$sqlConnection = New-Object System.Data.SqlClient.SqlConnection $sqlConnectionString + +Write-Host "connection string: "+$sqlConnectionString +Write-Host "connection: "+$sqlConnection + +# Create the Integration Services object +$integrationServices = New-Object $ISNamespace".IntegrationServices" $sqlConnection + +# Provision a new SSIS Catalog +$catalog = New-Object $ISNamespace".Catalog" ($integrationServices, "SSISDB", "P@assword1") +$catalog.Create() + +Write-Host "Catalog created: "+$catalog \ No newline at end of file diff --git a/CI/AKS/docker/ssis_scripts/deployISPAC.ps1 b/CI/AKS/docker/ssis_scripts/deployISPAC.ps1 new file mode 100644 index 000000000..789361956 --- /dev/null +++ b/CI/AKS/docker/ssis_scripts/deployISPAC.ps1 @@ -0,0 +1,88 @@ +# script to deploy ssis ispac file and run the file as a Windows Authenticated user on the SQL Server machine. +# Adapted from https://docs.microsoft.com/en-us/sql/integration-services/ssis-quickstart-deploy-powershell?view=sql-server-ver15 +# Adapted most recently from https://github.com/teach-for-america/ssiscicd/blob/master/docker/mssqlssis/deploy_ssis_package.ps1 + +param( + [string]$IspacUrl, + [string]$TargetFolderName, + [string]$ProjectFile, + [string]$ProjectName +) + +# Load the IntegrationServices Assembly +[Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Management.IntegrationServices") + +# Store the IntegrationServices Assembly namespace to avoid typing it every time +$ISNamespace = "Microsoft.SqlServer.Management.IntegrationServices" + +# Create a connection to the server +$sqlConnectionString = "Data Source=localhost;Initial Catalog=master;Integrated Security=SSPI;" +$sqlConnection = New-Object System.Data.SqlClient.SqlConnection $sqlConnectionString +Write-Host "Connecting to server ..." +Write-Host "connection string: "+$sqlConnectionString +Write-Host "connection: "+$sqlConnection + +# Create the Integration Services object +$integrationServices = New-Object $ISNamespace".IntegrationServices" $sqlConnection +Write-Host "IntegrationServices object: "+$integrationServices + +# Get the Integration Services catalog +$catalog = $integrationServices.Catalogs["SSISDB"] +Write-Host "Catalog: " +$catalog + +# Wait till catalog is available +while ($true){ + # Get the Integration Services catalog + $catalog = $integrationServices.Catalogs["SSISDB"] + if(!$catalog){ + Write-Verbose "Waiting for create SSISDB Catalog to complete." + Start-Sleep -Seconds 5 + } + else { + break + Write-Verbose "SSIS Catalog is available." + } +} + +$folder = $catalog.Folders[$TargetFolderName] + +if(!$folder){ + # Create the target folder + $folder = New-Object $ISNamespace".CatalogFolder" ($catalog, $TargetFolderName, "Folder description") + $folder.Create() + Write-Host "Folder created: " + $folder +} else { + Write-Host "Folder exists: " + $folder +} + +# $IspacUrl - url to download from Azure blob storage +Write-Host "Downloading " $IspacUrl " ispac file ..." + +$targetDir = "C:\SSIS_ISPACS"; + +if( -Not (Test-Path -Path $targetDir ) ) { + New-Item -ItemType directory -Path $targetDir + Write-Host "Folder created: " + $targetDir +} +else { + Write-Host "$targetDir Folder exists: " +} + +Invoke-WebRequest -Uri $IspacUrl -UseBasicParsing -OutFile "C:\SSIS_ISPACS\$ProjectFile" + +$ProjectFilePath="C:\SSIS_ISPACS\$ProjectFile" + +Write-Host "Folder: " + $folder +Write-Host "Deploying " $ProjectName " project ..." +Write-Host "From " $ProjectFilePath " project file path..." + +# Read the project file and deploy it +[byte[]] $projectFile = [System.IO.File]::ReadAllBytes($ProjectFilePath) +$folder.DeployProject($ProjectName, $projectFile) + +# Get the project +$project = $folder.Projects[$ProjectName] + +Write-Host "Project deployment complete... " $project "..." + +Write-Host "Done." \ No newline at end of file diff --git a/CI/AKS/docker/ssis_scripts/enableCLR.sql b/CI/AKS/docker/ssis_scripts/enableCLR.sql new file mode 100644 index 000000000..c07415b9a --- /dev/null +++ b/CI/AKS/docker/ssis_scripts/enableCLR.sql @@ -0,0 +1,8 @@ +sp_configure 'show advanced options', 1; +GO +RECONFIGURE; +GO +sp_configure 'clr enabled', 1; +GO +RECONFIGURE; +GO \ No newline at end of file diff --git a/CI/AKS/docker/ssis_scripts/setupSSIS.ps1 b/CI/AKS/docker/ssis_scripts/setupSSIS.ps1 new file mode 100644 index 000000000..a0a3add19 --- /dev/null +++ b/CI/AKS/docker/ssis_scripts/setupSSIS.ps1 @@ -0,0 +1,8 @@ +# from https://github.com/teach-for-america/ssiscicd/blob/master/docker/mssqlssis/setupSSIS.ps1 +Write-Verbose "Enable CLR Integration." +$enableCLRsqlcmd = "C:\SSIS_SCRIPTS\enableCLR.sql" +& sqlcmd -i $enableCLRsqlcmd + +Write-Verbose "Create SSIS Catalog." +$create_SSIS_Catalog_Script= "C:\SSIS_SCRIPTS\createSSISCatalog.ps1" +&$create_SSIS_Catalog_Script \ No newline at end of file