This tutorial provides instructions for setting up and running NopCommerce 3.1 on Microsoft Azure, utilizing Azure Cloud Services and Azure SQL Database.
Prerequisites
-
Software:
- Visual Studio 2012
- SQL Server 2012
-
NopCommerce Source Code:
- Download from nopCommerce Downloads.
Step 1: Local Setup
-
Extract the NopCommerce source code and open it in Visual Studio 2012.
-
In Visual Studio:
- Right-click on
Presentation/Nop.Web
and set it as the startup project. - Press
F5
to build and run the project locally.
- Right-click on
-
On the installation page:
- Provide your email address and create a password for the admin account.
- Check the Create Sample Data box.
- Select Use SQL Server and provide database details:
- SQL Server name:
localhost\SQLExpress
or equivalent. - Database name: e.g.,
nopDB
. - SQL Server admin credentials (default:
SA
with the password you set during installation).
- SQL Server name:
-
After installation, confirm that NopCommerce runs locally in the browser.
Step 2: Set Up Azure
-
Create an Azure Account:
- Sign up at Azure Portal for a free trial.
-
Create Azure SQL Database Server:
- Go to Azure Portal and navigate to SQL Databases.
- Create a new SQL Database:
- Choose Web Edition, 1GB.
- Configure admin credentials and save the server name (e.g.,
yourserver.database.windows.net
).
- Allow your local machine to access Azure SQL Server:
- Add your IP address under Configure > Allowed IP Addresses.
-
Migrate Local Database to Azure:
- In SQL Server Management Studio (SSMS):
- Right-click your NopCommerce database and select Tasks > Deploy Database to SQL Azure.
- Provide Azure SQL Server details and credentials.
- Complete the migration process.
- In SQL Server Management Studio (SSMS):
Step 3: Configure Azure Project in Visual Studio
-
Add an Azure Cloud Service project to your solution:
- Right-click the solution > Add > New Project > Visual C# > Cloud > Windows Azure Cloud Service.
- Name it
nopAzure
.
-
Configure settings for Nop.Web:
- Under
Presentation\Nop.Web\References\Microsoft.Web.Infrastructure
, set Copy Local toTrue
. - Add
Nop.Web
as a Web Role undernopAzure/Roles
.
- Under
-
Publish the project to Azure:
- Right-click
nopAzure
> Publish. - Sign in to Azure to import credentials.
- Create a new Cloud Service and storage account.
- Enable Remote Desktop and Web Deploy for all roles.
- Complete the publishing process.
- Right-click
Step 4: Finalize Azure Configuration
-
Use Remote Desktop to access the Azure instance:
- Go to Cloud Services in the Azure Portal.
- Select the instance and connect via Remote Desktop using credentials set during publishing.
-
Configure
Settings.txt
:-
Navigate to
F:\sitesroot\0\App_Data
on the Azure instance. -
Create
Settings.txt
with the following content:DataProvider: sqlserver DataConnectionString: Data Source=tcp:{server name}.database.windows.net,1433; Initial Catalog={database name}; Integrated Security=False; Persist Security Info=False; User ID={username}@{server name}; Password={password}; MultipleActiveResultSets=True
-
Step 5: Access Your Azure-Hosted NopCommerce
Visit {cloud service name}.cloudapp.net
to access your NopCommerce site hosted on Azure.
Troubleshooting
-
Admin project issues:
- Edit the local
Settings.txt
to match Azure configurations for synchronized admin access.
- Edit the local
-
For efficient publishing without recreating VMs, explore deployment strategies that retain configuration files.