Click here to Skip to main content
15,895,667 members
Articles / Programming Languages / C# 5.0
Tip/Trick

Microsoft Azure - Create Cloud Service with specific .NET Framework

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
27 Sep 2015CPOL2 min read 9K   2  
This is a short manual on how to create and configure cloud service on azure with a specific version of .NET Framework
 
 
STEP1:
Create new project on solution of type Azure Cloud Service
 
 
STEP2:
Add existing web role to the cloud service
 
 
STEP3:
Add some changes to support .Net Framework 4.5.2. on cloud service
 
  1. Download the .NET 4.5.2 Web Installer 
  2. For a Web Role
    • In Solution Explorer, under In Roles in the cloud service project right click on your role and select Add>New Folder. Create a folder named bin
    • Right click on the bin folder and select Add>Existing Item. Select the .NET installer and add it to the bin folder.
    • Files added this way to the Role Content Folder will automatically be added to the cloud service package and deployed to a consistent location on the virtual machine. Repeat this process for all web and worker roles in your Cloud Service so all roles have a copy of the installer
  3. Define startup tasks for your roles. Startup tasks allow you to perform operations before a role starts. Installing the .NET Framework as part of the startup task will ensure that the framework is installed before any of your application code is run.
  4. Add the following to the ServiceDefinition.csdef file under the WebRole node for all roles:
  5. Create the install.cmd file with the following content:

 

PowerShell
Editar Script|Remove
REM install.cmd to install .NET Framework 
 
set timehour=%time:~0,2% 
 
set timestamp=%date:~-4,4%%date:~-10,2%%date:~-7,2%-%timehour: =0%%time:~3,2% 
 
set startuptasklog=%PathToInstallLogs%\startuptasklog-%timestamp%.txt 
 
set netfxinstallerlog = %PathToInstallLogs%\NetFXInstallerLog-%timestamp% 
 
echo Logfile generated at: %startuptasklog% >> %startuptasklog% 
 
echo Checking if .NET 4.5.2 is installed >> %startuptasklog% 
 
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" /v Release | Find "0x5cbf5" 
 
if %ERRORLEVEL%== 0 goto end 
 
echo Installing .NET 4.5.2. Log: %netfxinstallerlog% >> %startuptasklog% 
 
start /wait %~dp0NDP452-KB2901954-Web.exe /q /serialdownload /log %netfxinstallerlog% 
 
:end 
 
echo install.cmd completed: %date:~-4,4%%date:~-10,2%%date:~-7,2%-%timehour: =0%%time:~3,2% >> %startuptasklog%
STEP4:
 
The install script checks whether .NET 4.5.2 is already installed on the machine by querying the registry. If .NET 4.5.2 is not installed then the .Net Web Installer launched. To help troubleshoot with any issues the script will log all activity to a file named startuptasklog-(currentdatetime).txt stored in InstallLogs local storage. Add the install.cmd file to all roles by right click on the role and selecting Add>Existing Item.... So all roles should now have the .NET installer file as well as the install.cmd file.
 

STEP5:

Publish to Microsoft Azure

 

Resources

Some good resources about Signal could be found here:

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Devscope
Portugal Portugal
I am João Sousa, and since i finish my degree I’m working in software development using Microsoft technologies.

I was awarded

Microsoft Most Valuable Professional (MVP) 2015 – .Net

My profissional profile:

Azure Developer
.NET Developer

My Certifications:

MCTS - .NET Framework - Application Development Foundation
MCTS - .NET Framework 2.0 - Windows-based Client Development
MCTS - .NET Framework 3.5 ADO.NET Applications
MCTS - .NET Framework 3.5 ASP.NET Applications
MCSD - Programming in HTML5 with JavaScript and CSS3
MCSD - Developing ASP.NET MVC 4 Web Applications
MCSD - Developing Windows Azure and Web Services
MCSA Office 365 - Managing Office 365 Identities and Requirements
MCSA Office 365 - Enabling Office 365 Services
MCSD - Implementing Microsoft Azure Infrastructure Solutions

Comments and Discussions

 
-- There are no messages in this forum --