Search

Categories

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Send mail to the author(s) E-mail

# Tuesday, 16 February 2016

Exploring workflows of

  • DB Project in VS2015
  • Appveyor
  • Deploying to Azure

with the end goal of having a well tested app, which has good automated deployment.

image

So, easy to easily redeploy a standard db

If I put a BookTech.mdf and .ldf in the IntegrationTests project then in Appveyor, before tests, run this PS:

$startPath = "$($env:appveyor_build_folder)\BookTechSite.IntegrationTests\bin\debug\"
$sqlInstance = "(local)\SQL2014"
$dbName = "BookTech"

# replace the db connection with the local instance
$config = join-path $startPath "BookTechSite.IntegrationTests.dll.config"
$doc = (gc $config) -as [xml]
$doc.SelectSingleNode('//connectionStrings/add[@name="BookTechConnectionString"]').connectionString = "Server=$sqlInstance; Database=$dbName; Trusted_connection=true"
$doc.Save($config)

# attach mdf to local instance
$mdfFile = join-path $startPath "BookTech.mdf"
$ldfFile = join-path $startPath "BookTech_log.ldf"
sqlcmd -S "$sqlInstance" -Q "Use [master]; CREATE DATABASE [$dbName] ON (FILENAME = '$mdfFile'),(FILENAME = '$ldfFile') for ATTACH"

this works, but clunky.

dacpac

This is working well and great to have the database source controlled.

https://bitbucket.org/davemateer/booktech/src

https://www.appveyor.com/docs/deployment/sql-database-ssdt

https://github.com/FeodorFitsner/dacpac-sample/blob/master/appveyor.yml – useful starting config file

https://www.appveyor.com/docs/build-configuration#secure-variables - Connection strings are encrypted

https://ci.appveyor.com/tools/encrypt – took to encrypt

 

version: 1.0.{build}

environment:
  # CI Appveyor connection string - if this Environment Variable is present, then the Repository code uses this connection string.
  AppveyorSQL2014ConnectionString: Server=(local)\SQL2014;Database=BookTech;User ID=sa;Password=Password12!
 
  # Live Azure db connection string - encrypted using tool in Appeyor UI
  # Server=tcp:booktechserver.database.windows.net,1433;Database=booktech2;User ID=dave@booktechserver;Password=******;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;
  # update line 45 too!
  BookTechConnectionString-Web.config Connection String:
    secure:  LCcX3rMYSmcHDQ966zbpW/sUFD1xQe3J0mwAzYj7t/y1r25psjHhoU6lBVmlZyhQYPGumsxvPQ20IZRJohWCVMRYxiSmkvJWKHT9yO9HMKPr1HRLnjt6iYKExQD30KnQUAjc93DNWFtCax4lSXlP5rjUC3ssx7XJJTdQ4MwTI9LHhBH7CBQuWvTNqMTQ8ps+X3Hl4T1zXnUJY/0x0olFvxqDPuY1PlQt8hd69Jc9l2yA4vaG/QAKiGsKtmUnc4EV
  matrix:
  - {}
 
services: mssql2014

# deploy .dacpac package to local SQL Server instance for integration testing
after_build:
  - '"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:dbDacFx="C:\projects\BookTech\BookTechDatabase\bin\Debug\BookTechDatabase.dacpac" -dest:dbDacFx="%AppveyorSQL2014ConnectionString%",dacpacAction=Deploy,CreateNewDatabase=True'
      
before_build:
  - cmd: appveyor-retry nuget restore

build:
  publish_wap: true
  verbosity: minimal

artifacts:
  - path: BookTechDatabase\bin\debug\BookTechDatabase.dacpac
    name: BookTech 
 
deploy:
  # Deploy website to Azure
  - provider: WebDeploy
    server: https://booktech.scm.azurewebsites.net/msdeploy.axd?site=booktech
    website: booktech
    username: $booktech
    password:
      # Was put in via the UI and exported to yml - essentially the publish settings for the website from Azure
      secure: rkp03SX+duzOUKu/ZRymYUXI4b6OIXIrEzIIDm2605q8MBTBlrQwxGN8zxCCovEYj2lkv5qoMvy8TTAW+zASVA==
    remove_files: true
   
    # Deploy Database to Azure - firewall rules are setup on Azure side to allow inbound connections..
  - provider: SqlDatabase
    artifact: BookTech
    # Same as line 8
    connection_string:
      secure:  LCcX3rMYSmcHDQ966zbpW/sUFD1xQe3J0mwAzYj7t/y1r25psjHhoU6lBVmlZyhQYPGumsxvPQ20IZRJohWCVMRYxiSmkvJWKHT9yO9HMKPr1HRLnjt6iYKExQD30KnQUAjc93DNWFtCax4lSXlP5rjUC3ssx7XJJTdQ4MwTI9LHhBH7CBQuWvTNqMTQ8ps+X3Hl4T1zXnUJY/0x0olFvxqDPuY1PlQt8hd69Jc9l2yA4vaG/QAKiGsKtmUnc4EV

| | # 
# Wednesday, 25 November 2015

image

image

I did have this on Azure to stop robots

image

Robots should be good now

http://www.appveyor.com/docs/deployment/web-deploy

| | # 
# Thursday, 19 November 2015
( Appveyor | GitHub )

To setup an auto build for a GitHub hosted project, go to, appveyor and add the project

Then it will setup the WebHook in GitHub for you.

In Before build section:
nuget restore

Put in the badge in your README.MD file

It will also run the tests for you

| | # 
# Saturday, 07 March 2015

Continuous Integration (CI)

  • hosted build environment
  • hosted testing

Continuous Deployment (CD) system

  • deploys to Azure using WebDeploy

Workflow

  • Develop app locally
  • Commit to git locally
  • Push to GitHub
  • AppVeyor automatically gets any updated source
  • AppVeyor does a build
  • AppVeyor runs all tests
  • On success AppVeyor transforms web.config connection string into the live connection string (which is kept securely in AppVeyor not GitHub), 
  • AppVeyor deploys to Azure website using WebDeploy.

image
https://github.com/djhmateer/davesmusic

Build

Free version uses AzureVM's 1.75GB RAM
Max build time is 40mins
Does take its time

First build failed with lots of errors like:

Could not resolve this reference. Could not locate the assembly "System.Web.Helpers, Version=3.0.0.0

http://andythecoder.com/blog/index.php/2014/10/26/continuous-integration-in-the-cloud/
http://blog.appveyor.com/blog/2014/03/18/about-nuget-package-restore

image
Put in nuget restore to get packages

Tests

https://github.com/mmaitre314/TestStatusBadge

image
Included some MSTests – just ran.

Can use their local db to run integration tests

Deploy

image

WebDeploy to Azure worked fine.

Web.config transformed into the live connection string took effort:

http://help.appveyor.com/discussions/problems/1759-webconfig-using-web-deploy

| | #