Move Passwordstate To Azure Environment
Instructions for Migrating an On-Premise installation of Passwordstate to Azure Virtual Machine with an Azure SQL Database.
Overview
Please use the following instructions as a guide for moving an existing Passwordstate Website and Database to Azure.
This guide assumes you are currently running Passwordstate 9 or above.
This guide also assumes you are intending on using an Azure SQL database - https://azure.microsoft.com/en-au/products/azure-sql/database instead of a self-hosted Microsoft SQL install on an Azure Virtual Machine.
Note: You can leave your current production instance of Passwordstate running until you can confirm that the migration has worked. Once you can confirm the new website works, then you should decommission the old server.
Note: Please be aware of the instructions below where it instructs you to download the correct build number of Passwordstate. Versioning is important, depending on what build your current server is running.
Note: If you have encrypted your database Connection string, or AppSettings section of the web.config file, you will need to decrypt these prior to moving this file. Information about what an encrypted web.config file looks like, and how to decrypt it can be found in this forum post. Decrypt/Encrypt Web.config
Preparation Required
Ensure your new Virtual Machine in Azure is built with a Microsoft Operating System that meets the Passwordstate system requirements: https://www.clickstudios.com.au/passwordstate-system-requirements.aspx
In your Azure portal, you’ll need to create a SQL Server if you do not have one already, with an Admin account that you know the credentials for.
Consider preparing DNS and your SSL certificate for the new web server, and if you will need any open ports for incoming HTTPS traffic.
Log in to your current on-premise Passwordstate instance and add the new web server name to the list of authorized web servers. The Server Role you specify for this when adding it in should be “Primary Server”. You can do this from the screen Administration -> Authorized Web Servers
Take note of your Emergency password, just in case you need to use this later in this migration process. This password can be found under Administration -> Emergency Access
Take a backup of your existing Passwordstate instance, which includes the web installation files, and the database. Passwordstate has its own backup feature you may have already configured you can use under Administration -> Backups, or you can use your own 3rd party backup solution if you have one. Another option is to back up the data manually using this guide: Manual Backup Using SQL Management Studio Tool
Install Passwordstate on the New Webserver
On your new server, you will now need to download the latest Passwordstate installation files from Click Studios check sums page: https://www.clickstudios.com.au/passwordstate-checksums.aspx
Now you can follow the General Installation Instructions to install Passwordstate, stopping when you complete section Installing Passwordstate. You should not proceed to 'Configuring Passwordstate for First Time Use'
Next, configure your HTTPS IIS Binding to match your existing web server if you intend on keeping the same URL. Otherwise, set your HTTPS binding to any new value you like.
Assign your SSL Certificate to your HTTPS binding that you previously prepared on your new server. If you intend on using a new certificate, more information about SSL Certificates can be found here: Passwordstate Certificates Explained
You will most likely be using an existing CNAME DNS entry to resolve the URL to your old web server. You will now need to edit the DNS entry and update the host name of your new web server, or you can create a new CNAME entry pointing to the new server.
Next you need to copy the entire ConnectionStrings and AppSettings sections from your existing installation’s web.config file into the new website. (The default location for the web.config file is C:\inetpub\Passwordstate*web.config*)
Example of these lines that need copying can be seen in screenshot below:

- At this point, do not log into this new website, instead follow the next section of this guide which will advise how to migrate your database.
Migrating the Database
- Open SSMS (SQL Server Management Studio) and connect to your existing on-premise database server
- Right-click your Passwordstate database and select Deploy Database to Microsoft Azure SQL Database…

- Click Next on the Introduction page

- Click Connect, and enter the details of your Azure SQL Server and the Admin credentials of the server. Now choose the Edition of database you wish to use and click Next

- When finished, click Close

At this point, your database has been migrated up to Azure. The on-premise passwordstate_user SQL account has been migrated up to the Azure SQL database, so we will need to remove this and recreate it, and assign it the correct permissions. To do this, use SSMS and connect to your Azure SQL Server
Delete the passwordstate_user account from the Security → Logins folder

- Click OK to the warning message:

- Also delete the passwordstate_user from the Security → Users folder inside the Passwordstate database

- Next, to recreate the user, run the following script and set a password of your choice:
SQL
USE master
CREATE LOGIN passwordstate_user WITH password='<choose a password>'
CREATE USER passwordstate_user FOR LOGIN passwordstate_user WITH DEFAULT_SCHEMA=[dbo]- Now you can assign the passwordstate user db_owner permissions by running this script:
SQL
USE passwordstate
CREATE USER passwordstate_user FOR LOGIN passwordstate_user WITH DEFAULT_SCHEMA=[dbo]
EXEC sp_addrolemember 'db_owner', 'passwordstate_user';- Now you need to make some final changes to your web.config file on your new webserver server. Open the c:\inetpub\passwordstate\web.config file and change the Data Source and Password in the connection string to be relevant to your new Azure SQL server. The password is what you set in Step #10 above.

- Restart the Passwordstate Windows Service on your new webserver (after the Service has been restarted, it will recreate any custom Logos or images you have uploaded into Passwordstate - you may need to give it a minute or two to do this)
- Now you can attempt to log into Passwordstate for the first time after this migration, and you will most likely be prompted to upgrade the database. This is normal, and you can continue at this point until the upgrade process finishes.
- If you now log in you should see all your data as it was when on premises. Everything including passwords, users, settings and license keys.
At this point, your Passwordstate instance has now been moved to Azure and your migration is complete. We encourage you to do some user acceptance testing, and when complete, you can safely decommission the old server.
This concludes the migration process, and if you have any queries about this, you are more than welcome to log a support call with Click Studio via our support page: https://www.clickstudios.com.au/support.aspx