Cloud Service
Cloud service gives you one of the possible ways to run your code in Azure. Another ways would be VMs, Websites, Azure App Service, Azure Fabric, Azure Functions and others.
- You can obtain Cloud Service in Azure Cloud
- Cloud service provides you with virtual machines (instances) that are managed by Azure. For example, if you’d like to use your own VMs, you need to provision those VMs first and install necessary software there. Also, this is you who is responsible for administrating (updating, patching, managing) your VMs. In case of Cloud Services all this work is done by Azure.
- You can run: Websites (as Web Roles) and other code (as Worker Roles) in Cloud Services
Cloud Service Application Roles
Application Role is a container for running your application code on virtual machines. It has two different types:
- Web Role – used to run websites with web interface. Web Role VM has: Windows server, .NET Framework, Native Code, IIS support, CGI support, PHP support
- Worker Role – used to run background processes (e.g. database updates or processing messages from event hubs). Worker Role VM has: Windows Server, .NET Framework, Native code
Responsibilities
Your responsibility:
- Create code logic (website or other code)
- Define for Azure how it should create a virtual machine, define the characteristics like: CPU, memory, hard drive space, how many instances you need (how many VMs)
Azure Responsibility:
- Azure Fabric will manage your Cloud Service according to cloud service definition you provided. It will monitor instances health, run your code, scale the service out upon your guidelines etc.
Configuration files
Azure will manipulate and manage your Cloud Service according to your guidelines that you have to provide in 2 types of configuration files.
Service Definition file
Extension: .csdef
Service Definition provides Azure with information about your service model telling how your application will look like from Azure perspective. You can provide such information as:
- VM size
- External (e.g. for web application to let customers reach the web out) and Internal Endpoints
- Certificates
- Site name, Bindings, protocol, ports
- Environment variables
- Configuration settings names
Example from ‘Azure Cloud Service: Practice‘:
<?xml version="1.0" encoding="utf-8"?> <ServiceDefinition name="RosesInCloud" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2015-04.2.6"> <WorkerRole name="RoseWorkerRole" vmsize="Standard_D1_v2"> <ConfigurationSettings> <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" /> <Setting name="APPINSIGHTS_INSTRUMENTATIONKEY" /> </ConfigurationSettings> </WorkerRole> </ServiceDefinition>
Service Configuration file
Extension: .cscfg file
Defines the configuration for particular servces:
- Operating System
- Instance count
- Values for configuration settings given in Service Definition file
- Certificate thumbprints
Example from ‘Azure Cloud Service: Practice‘:
<?xml version="1.0" encoding="utf-8"?> <ServiceConfiguration serviceName="RosesInCloud" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="6" osVersion="*" schemaVersion="2015-04.2.6"> <Role name="RoseWorkerRole"> <Instances count="1" /> <ConfigurationSettings> <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="DefaultEndpointsProtocol=https;AccountName=roses;AccountKey=MY_ROSES_KEY" /> <Setting name="APPINSIGHTS_INSTRUMENTATIONKEY" value="f0331000-0000-0000-0000-000394f5f72a" /> </ConfigurationSettings> </Role> </ServiceConfiguration>