Developing Azure projects locally

You can start developing the application in the local computing emulator provided by Azure SDK. You can use the emulator to test the website during its development without actually hosting it in the cloud.

You can use either a standard SQL database or Windows Azure SQL Database (note that when developing locally with a database in the cloud, you may experience slower performance based on the location of the server and database services). However, we recommend that you use a Windows Azure Storage account as a file system for your project.

Developing Azure projects locally in the emulator

  1. Prepare an SQL database or prepare a database on Windows Azure:

    1. Create new Windows Azure SQL Server.
    2. Add firewall rules for the server.
    3. Create SQL Database.
  2. Create a Windows Azure Storage account through the Windows Azure Management Portal.

  3. Open your Azure project in Visual Studio using the CMSAzure.sln file.

  4. Right-click the CMSAzure/Roles/CMSApp role and select Properties.

  5. Switch to the Settings tab.

  6. Select Local as the Service Configuration.

  7. Set the value of CMSConnectionString key to the connection string for your database.

    • You can find the connection string of Windows Azure SQL Database on the Windows Azure Management Portal in SQL Databases -> select the database -> Dashboard tab -> Show connection strings link.
  8. Set the values of CMSAzureAccountName and CMSAzureSharedKey keys for your Azure Storage.

    • You can find these values on the Windows Azure Management Portal in Storage -> select your storage -> Manage access keys (in the bottom panel) as Storage account name and Primary access key.
  9. Clear the values of CMSAzureQueueEndPoint, CMSAzureTableEndPoint and CMSAzureBlobEndPoint keys.

    Configuring the CMSApp role for local development

  10. Repeat steps 4 - 9 for the SmartSearchWorker role.

  11. Right-click the CMSAzure project in the Solution Explorer and select Set as StartUp Project.

  12. Run the project in the debug mode.

  13. Go through the Kentico database installation when the system automatically opens the database installation in a browser.

    • In case of Windows Azure SQL Server, use the following format of the server name: servername.database.windows.net.

      Windows Azure SQL Server settings

Your web project is now prepared to be developed on your local computer.

Developing Azure projects locally as web applications

If you are having trouble running your project in the local emulator, you can develop your Azure project as a normal web application project. We recommend this approach only if you do not plan to perform any customizations specific to Windows Azure environment.

  1. Prepare an SQL database or create new Windows Azure SQL Server and SQL Database.

  2. Create a Windows Azure Storage account through the Windows Azure Management Portal.

  3. Open your Azure project in Visual Studio using the WebApp.sln file.

  4. Open the CMSApp\Web.config file.

  5. Add the CMSConnectionString key and value to the <connectionStrings> section of the web.config file.

    
    
    
     <connectionStrings>
         <add name="CMSConnectionString" connectionString="Data Source=tcp:YourServerName.database.windows.net,1433;Initial Catalog=YourDatabaseName;User Id=YourUsername@YourServerName;Password=YourPassword;" />
     </connectionStrings>
    
    
     
    • Replace YourServerName, YourDatabaseName, YourUsername and YourPassword with your own values.
    • You can find the connection string of Windows Azure SQL Database on the Windows Azure Management Portal in SQL Databases -> select the database -> Dashboard tab -> Show connection strings link.
  6. Add the CMSAzureAccountName and CMSAzureSharedKey keys to the <appSettings> section of the web.config file.

    
    
    
     <appSettings>
         ...
         <add key="CMSExternalStorageName" value="azure" />
         <add key="CMSAzureAccountName" value="YourStorageAccountName" />
         <add key="CMSAzureSharedKey" value="YourPrimaryAccessKey" />
     </appSettings>
    
    
     
    • Replace YourStorageAccountName and YourPrimaryAccessKey with your own values.
    • You can find these values on the Windows Azure Management Portal in Storage -> select your storage -> Manage access keys (in the bottom panel) as Storage account name and Primary access key.
  7. Right-click the CMSApp project in the Solution Explorer and select Set as StartUp Project.

  8. Right-click the CMSApp_AppCode\Old_App_Code\CMSModules\WindowsAzure folder and select Exclude From Project.

  9. Run the project in the debug mode.

  10. Go through the Kentico database installation when the system automatically opens the database installation in a browser.

    • In case of Windows Azure SQL Server, use the following format of the server name: servername.database.windows.net.

You can now develop your project as a standard web application project.

Deploying locally developed Azure projects

When you are ready, you can move your locally developed Azure project to the production environment while still being able to make changes to the project locally. For this scenario to work, you must use only one instance of the CMSApp web role.

WindowsAzure folder

If you are developing your project locally as a web application, you need to return the WindowsAzure folder to your project before the deployment. The folder contains the AzureInit.cs file, which is essential for running your project on Microsoft Azure.

  1. Open your Azure project in Visual Studio using the CMSAzure.sln file.
  2. Select Show all files on the Solution Explorer panel.
    • This option displays folders and files which are excluded from the project.
  3. Open the CMSApp_AppCode\Old_App_Code\CMSModules folder.
  4. Right-click the WindowsAzure folder and select Include in project.

The system includes the AzureInit.cs file back into the project.

Deployment with migration to a new database

This procedure presumes that you used a local SQL database and you want to migrate the database to the Windows Azure SQL Database.

  1. Export your website from Kentico database in Sites application -> Export site.

  2. Create Cloud Service.

  3. Create new Windows Azure SQL Server.

  4. Create SQL Database.

  5. Open your Azure project in Visual Studio using the CMSAzure.sln file.

  6. In Properties of the CMSApp web role, on the Settings tab, in the Cloud service configuration, fill the CMSAzureAccountName and CMSAzureSharedKey keys with appropriate values for your Azure Storage (the same as for the Local configuration).

  7. Set the CMSConnectionString value with the connection string of the new database.

  8. Configure the SmartSearchWorker role.

  9. Deploy your project to the created Cloud Service.

    • Make sure that the Enable Remote Desktop for all roles and Enable Web Deploy for all web roles (requires Remote Desktop) are selected.
  10. Install a new database for your project.

  11. Import the previously exported website in Sites application -> Import site or objects.

Now you can deploy changes to the project files quickly using the Web deploy functionality.

Deployment when using the same database

This procedure presumes that you are using the Windows Azure SQL Database from the beginning and you do not need to migrate the database.

  1. Create Cloud Service.

  2. Open your Azure project in Visual Studio using the CMSAzure.sln file.

  3. In Properties of the CMSApp web role, on the Settings tab, in the Cloud service configuration, fill the CMSAzureAccountName and CMSAzureSharedKey keys with appropriate values for your Azure Storage (the same as for the Local configuration).

  4. Set the CMSConnectionString value with the connection string of your database (the same as for the Local configuration).

  5. Configure the SmartSearchWorker role.

  6. Deploy your project to the created Cloud Service.

    • Make sure that the Enable Remote Desktop for all roles and Enable Web Deploy for all web roles (requires Remote Desktop) options are selected.

Now you can deploy changes to the project files quickly using the Web deploy functionality.

Web Deploy

If you are performing web deploy from the same computer from which you performed the initial deployment, this procedure is straightforward as you can use an already created publish profile:

  1. Right-click the CMSApp project and select Publish.
  2. Select the existing publish profile from the drop-down list.
  3. Switch to the Connection tab.
  4. Provide the password for remote desktop connection.
  5. Click Publish.

If you are performing web deploy from a different computer than the one from which you performed the initial deployment, you need to create a new publish profile:

  1. Right-click the CMSApp project and select Publish.

  2. Click the drop-down list and select <New profile…>.

  3. Type the name of the profile and click OK.

  4. On the Connection tab, select Web Deploy as the Publish method.

  5. Provide the Server address:

    1. Open Windows Azure Management Portal in a browser.

    2. Select Cloud services -> your cloud service -> Dashboard tab.

    3. Copy the Site URL without the protocol (http://) and trailing slash (/) to the Server field of the web deploy profile in the following format:

      
      
      
       https://YourSiteURL:8172/MsDeploy.axd
      
      
       
  6. Provide the Site name:

    • This corresponds to the name of your website registered in IIS of the server.
    • You can find the name by remotely connecting to the server (Cloud services -> your cloud service -> Instances tab -> Click Connect in the bottom panel and run the downloaded file).
    • The default value is CMSApp_IN_0_Web.
  7. Type the username and password for remote desktop connection.

    Configuring Web Deploy for Azure projects

  8. Switch to the Settings tab.

  9. Choose the build Configuration.

  10. Click Publish.

Final deploy

When your project is fully developed and ready to go live, Deploy your project again, with the Enable Remote Desktop for all roles and Enable Web Deploy for all web roles (requires Remote Desktop) options CLEARED. After that, your CMSApp web role can use more than one instance.