Moving ASP.NET Apps to Azure
Migrating the ASP NET application to Windows Azure for newbies is a challenging task. However, with little patience and meeting prerequisites, you can handily replenish this otherwise which is a demanding task. Before you start, make sure to have an active Azure account and a working SQL Azure Database.
If you don’t have one, set up a new account at the Azure store and create a temporary database ‘database_alfa’ in SQL Server Management Studio. Also, make sure that your firewall settings do not stop your ASP NET application from running. Microsoft Azure lets you focus on business ideologies while Azure takes care of the foundation and open-ended maintenance to manage the apps.
The step by step guidance in migrating database is as follows:
- Migrate the alfa.MDF (application)
- Migrate ASP.NET application development service providers
- Change the connection strings
1. Migrating Alfa.MDF
- Open SQL Server Management and connect using .SQLExpress.
- Select ‘Attach’ under Database.
- Select ‘Add’ and locate ‘alfa.MDF’ from your directory, upload it.
- Select alfa database (that you just added), Select Tasks-> Generate Scripts.
- Click Next twice and select ‘Advanced’ under Set Scripting Options.
- Scroll to ‘Script for database engine type’ and opt ‘SQL Azure Database’.
- Based on your type of data, select related script option from schema only, the schema and data or data only.
- Save the script file and open it in SSMS.
- Our next task here is to connect to SQL Azure. Right Click Connect button from Object Explorer and choose ‘Database Engine’.
- When asked server name, write your SQL Azure portal name with your domain name. i.e. zkymadd998.database.windows.net. Also enter the same Server name in Connect to Server dialog for SSMS.
- Login to your SQL Azure portal.
- Select ‘Options->Connection Properties’ and enter alfa.db against ‘Connect to database’, this shall place the SQL Azure database in SSMS object explorer.
- Open a new SQL Query window from ‘New Query’ option under SQL Azure Database.
- Execute the query window after copy, pasting the database script. Successful query execution would appear after running your query against the alfa.db.
2. Migrate ASP.NET providers
- Import your scripts and extract them from existing data source.
- Open InstallCommonSQL script from SSMS and select ‘Connection | Disconnect’ from query window in order to connect to ‘beta.db’.
- Right Click SQL Query window, and enter beta.db as the connect to database.
- Run script; open InstallMembership.SQL and installprofile.SQL, and run them against beta.db.
3. Changing Connection String
- Finally, we need to change our connection strings in connectionstrings.config file in our project.
- Change the user ID and Password, also change the database source. It should look something like this:
< connectionStrings > < add name=”ApplicationServices” connectionString=”Server=tcp: zkymadd998.database.windows.net; Database=alfadb;User ID=jnak;Password =< enter >;Trusted_Connection=False;” providerName=”System.Data.SqlClient” /> < add name=”AlfaConnectionString” connectionString=”Server=tcp: zkymadd998.database.windows.net; Database=betaDB;User ID=jnak;Password=;Trusted_Connection=False;” providerName=”System.Data.SqlClient” /> connectionStrings >
Remove database files from App Data and execute.
#ASP.NET application #Windows Azure #Cloud #SQL Azure # MS SQL #asp.netdevelopers #webdeveloper