The xDatabase module contains the xDatabase and xDBPackage resources. xDatabase handles creation/deletion of a database using a dacpac or SQL connection string. xDBPackage allows extraction of a dacpac or import of a bacpac from a database. For information on Data-Tier Applications please refer to http://technet.microsoft.com/en-us/library/ee240739(v=sql.105).aspx.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.
Please check out common DSC Resources contributing guidelines.
- xDatabase handles creation/deletion ofa database using a dacpac or sql connection string.
- xDBPackage allows extraction of a dacpac or import of a bacpac from a database.
- Credentials: The credential to connect to the SQL server.
- SqlServer: The SQL server.
- SqlServerVersion: The version of the SQL Server. This property can take the following values: { 2008-R2 | 2012 | 2014 }
- BacPacPath: The path to the .bacpac file to be used for database restore If this is used, the DacPacPath (see below) cannot be specified.
- DacPacPath: The path to the .dacpac file to be used for database schema deploy. If this is used, the BacPacPath (see above) cannot be specified.
- DacPacApplicationName: For deploying a database using .dacpac file, an application name with which the dacpac is registered. This is needed to support database upgrade using .dacpac files. This must specified if DacPacPath is provided.
- DacPacApplicationVersion: This is an optional parameter needed for registration for database deployment using .dacpac files for dacpac registration.
- DatabaseName: The name of the database to be deployed.
- DatabaseName: The name of the database to be deployed.
- SqlServer: The SQL server.
- SqlServerVersion: The version of the SQL Server. This property can take the following values: { 2008-R2 | 2012 | 2014 }
- Path: The path to the .bacpac or .dacpac file to be used to export a database to a bacpac or extract a db to a dacpac respectively.
- Type: This property can take the following values for dacpac extraction and bacpac export: { DACPAC | BACPAC }
- Added support SQL Server 2016
- Moved internal functions to a common helper module
- Converted appveyor.yml to install Pester from PSGallery instead of from Chocolatey.
- Added logging for when dac deploy fails
- Error output improvements
- Fixed mandatory attributes in schema
- Removed parameter DefaultDatabaseName
- Alligned *.schema.mof with *.psm1 files
- Improve support for Credentials.
- Minor bug fixes
- Initial release with the following resources
- xDatabase
- xDBPackage
This configuration will deploy the database with the schema specified in the dacpac. If the db exists, the new schema will be deployed.
configuration DacDeploy
{
param
(
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$Ensure,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$DatabaseName,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$SqlServer,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$SqlServerVersion,
[String]$DacPacPath,
[String]$BacPacPath,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$NodeName,
[PSCredential]
$Credentials,
[string]$DacPacApplicationName
)
Node ‘NodeName’
{
xDatabase DeployDac
{
Ensure = $Ensure
SqlServer = $SqlServer
SqlServerVersion = $SqlServerVersion
DatabaseName = $DatabaseName
Credentials = $Credentials
DacPacPath = $DacPacPath
DacPacApplicationName = $DacPacApplicationName
}
}
This configuration will deploy the database with the schema and data specified in the bacpac If the database exists, no action is taken.
configuration BacPacDeploy
{
param
(
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$Ensure,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$DatabaseName,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$SqlServer,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$SqlServerVersion,
[String]$DacPacPath,
[String]$BacPacPath,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$NodeName,
[PSCredential]
$Credentials,
[string]$DacPacApplicationName
)
Node ‘NodeName’
{
xDatabase DeployBacPac
{
Ensure = $Ensure
SqlServer = $SqlServer
SqlServerVersion = $SqlServerVersion
DatabaseName = $DatabaseName
Credentials = $Credentials
BacPacPath = $BacPacPath
}
}
}
This configuration will create a database when neither a .dacpac nor a .bacpac is specified.
configuration DbDeploy
{
param
(
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$Ensure,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$DatabaseName,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$SqlServer,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$SqlServerVersion,
[String]$DacPacPath,
[String]$BacPacPath,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$NodeName,
[PSCredential]
$Credentials,
[string]$DacPacApplicationName
)
Node ‘NodeName’
{
xDatabase DeployDatabase
{
Ensure = $Ensure
SqlServer = $SqlServer
SqlServerVersion = $SqlServerVersion
DatabaseName = $DatabaseName
Credentials = $Credentials
}
}
}