nopCommerce is an open source online shopping engine written in ASP.NET MVC. The project is being developed by our compatriots from the city of Yaroslavl, and today more than 20,000 sites operate on its basis, including such brands as Volvo, Turkish Airlines, Reebok.
A few days ago, a new version of the product 3.70 was released, in which developers added full support for Windows Azure. In previous versions, store owners could use only one instance in Azure, but now support has been added for several. Therefore, in fact, this functionality can be used on web farms. This opens up excellent opportunities for scaling the application.
Suppose that you have already downloaded (
http://www.nopcommerce.com/downloads.aspx ) and installed (
http://docs.nopcommerce.com/display/nc/Installing+nopCommerce ) nopCommerce in Azure. So, what was done to support Azure, and how to set it up and enable it:
Blob storage
Now you can configure the storage of resources (for example, images of products and categories) as blobs, and not just store on the file system, as is done by default. You can read more about the storage service in Azure here (
https://azure.microsoft.com/ru-ru/documentation/articles/storage-introduction/ ).
')
How to configure in nopCommerce:- Of course, you first need to create a BLOB storage account in Windows Azure. This procedure is well described here ( https://azure.microsoft.com/ru-ru/documentation/articles/storage-create-storage-account/ )
- Then you can get the connection string, container and endpoint from this repository.
- Now you need to open the web.config file in nopCommerce. Find the XML element AzureBlobStorage and enter the connection string, container and endpoint that you received earlier
- Once this is done, your resources will be stored in Azure Blob.
Caching and distributed sessions
Of course, in any distributed application we need to have support for distributed caching and sessions. Otherwise, different instances of the application will use different data. We chose Redis (
http://redis.io/ ) to implement this functionality, since Azure and many other cloud services already support it.
How to configure in nopCommerce:- First install Redis. How to use Redis in Azure is well written here ( https://azure.microsoft.com/ru-ru/documentation/articles/cache-dotnet-how-to-use-azure-redis-cache/ ).
- Once the previous step is complete, we need to copy and specify the connection string from Redis in the web.config file in nopCommerce. Find the XML element “RedisCaching”, set the attribute “Enabled” to “True”, and then in the next attribute specify the connection string to Redis itself. Now all cached data is stored in Redis.
- Now do the same for the sessions. Open the web.config file again, uncomment the “sessionState” element and specify in it the same connection string that was used in the previous step.
<sessionState mode="Custom" customProvider="MySessionStateStore"> <providers> <add name="MySessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" host="localhost" accessKey="" ssl="true" /> </providers> </sessionState>
Schedule tasks
And the last step. nopCommerce uses background tasks for various actions that should be performed automatically. For example, sending mail or updating currency rates. Of course, when we have several instances (instances) of an application, such tasks should be performed only on one of them. Otherwise, a situation may occur when the same letter comes to the buyer twice (from each of the application copies).
nopCommerceAll also open the web.config file. Find the XML element “WebFarms” and set its attribute “MultipleInstancesEnabled” to “True”. For a web farm this will be enough, but in Windows Azure you will also need to set the attribute "RunOnAzureWebsites" to "True"
That's all. Now nopCommerce is ready to fully work in Azure on multiple instances. You no longer have to think about whether there is enough server capacity to serve a large number of customers.