0
votes

I want to run tests using real SQL databases. The SQL server and the databases would be on Azure. I'm trying to configure a build definition on VSTS where the tasks would set up an Azure resource group with the databases, set the connection strings on my solution and run the Entity Framework Core migrations to the databases. After the tests a task should delete the resource group.

I created an Azure resource group with the databases I need and downloaded the PowerShell deployment files, the script, template.json and so on.

The PowerShell script task can have an inline script or a path to the script. Should I add the Powershell scripts to the solution so that the VSTS could access them? The inline script option seems to be for small few line scripts and the Azure deployment is quite big with multiple files.

Setting up the connection strings shouldn't be too difficult. Several people suggest using the Replace Tokens task from the market place.

I'm not sure how to run the database migrations after that. Can I run the migrations on PowerShell script task? How can I ensure that the needed cmdlets work?

1
What's the result after trying it with database project?starian chen-MSFT
@starain-MSFT I created databases by using PowerShell script and a template from Azure and installed .NET Core SDK on the build and used the CLI tools to update the databases. That seems to work for now. I'll have to keep the database project option in mind for the future. Thanks for your help.VilH

1 Answers

0
votes

Since the script is quite big, you can’t use Inline script, you can add it to the project or other path of server (Add additional mapping for different path).

Regarding database migration, if you enabled EF migration in a web app, you can create a publish profile (web deploy package) with database migration enabled, then publish/deploy with /p:DeployOnBuild=true /p:PublishProfile=[profile name];DesktopBuildPackageLocation="$(build.artifactstagingdirectory)\webEF.zip" MSBuild arguments, then deploy package to Azure Web APP through Azure Web Deploy task.