1
Smart Embedded System Lab
Smart Embedded System Lab
Kookmin University
Smart Embedded System Lab
Microsoft Azure
Week6 Tuesday
- Objectives and what to study
Window Azure Cloud Service Concepts
Window Azure Cloud Service Development
Deploy offline
Create an Azure storage account
Deploy on Azure cloud
3
Smart Embedded System Lab Smart Embedded System Lab
Objectives
Understand basic concepts of Window Azure Cloud
Service
What to study
How to setup the environment to develop Window
Azure Cloud Service application
Develop a simple Window Azure Cloud Service applicat
WINDOW AZURE
CLOUD SERVICES
5
Smart Embedded System Lab Smart Embedded System Lab
Reference from Microsoft Azure Website
http://azure.microsoft.com/ Reference from Microsoft Azure Website
7
Smart Embedded System Lab Smart Embedded System Lab
Reference from Microsoft Azure Website
Click on “Cloud Services” tab Microsoft Azure provides sample code and explanation to develop app
lications applying Azure services
Link:
https://code.msdn.microsoft.com/windowsazure/
9
Smart Embedded System Lab Smart Embedded System Lab
Cloud Services explanation
Compute• Create a multi-tier .NET application with an ASP.NET • Build a .NET multi-tier app with Service Bus Queues
• Create a multi-tier app using Storage Tables, Queues, and Blobs • Configure SSL for a cloud service
• Configure a custom domain name for a cloud service • Cloud service roles
Deployment & source control
• Manage cloud service deployments to staging and production • Publishing Cloud Services from Visual Studio
• Continuous delivery to Azure using Visual Studio online and Git • Continuous delivery to Azure using Visual Studio Online
Cloud Services samples
Data• Azure data management and analytics services • Blob Storage
• Table Storage • Queue Storage • SQL Database
• Managing SQL Database using SSMS
11
Smart Embedded System Lab Smart Embedded System Lab
Cloud Services samples
App services• Azure Active Directory • Service Bus Queues • Service Bus Topics • Event Hubs
• Service Bus Relay • Service Bus AMQP
• Upload, encode, and stream media with Media Services • Scheduler
• Send email using SendGrid
• Use Twilio for phone calls and SMS • Use Blitline for image processing
Cloud Services samples
App services Cloud ready
• Building real-world cloud applications • Cloud design patterns
• Managed Cache • Redis Cache • In-role cache
• Azure Content Delivery Network (CDN)
13
Smart Embedded System Lab Smart Embedded System Lab
This tutorial shows how to create a multi-tier .NET application with an
ASP.NET MVC front-end, and deploy it to an Azure cloud service.
Use
Azure SQL Database Azure Blob service Azure Queue service
The Contoso Ads application
Description• An advertising bulletin board
• Users create ads by entering texts and uploading images. Code:
• http://code.msdn.microsoft.com/Simple-Azure-Cloud-Service-e01df2e4
Start
• Uncompress code • Open project
Error
Packages’ Error
Reason: not yet added Reference packages to the namespaces Solution:
• Download reference packages using NuGet
15
Smart Embedded System Lab Smart Embedded System Lab
Error
Right click on solution of the project Click “Restore”
Project will automatically install required packages Click Close button
Set ContosoAdsCloudService as the st
artup project
Ctrl + F5 to start application
Visual Studio automatically invokes the
Azure
compute emulator
and Azure
stora
ge emulator
.
The compute emulator uses your comput er's resources to simulate the web role a nd worker role environments.
The storage emulator uses a SQL Server Express LocalDB database to simulate Az ure cloud storage
17
Smart Embedded System Lab Smart Embedded System Lab
Create an Ad
Enter data and select a .jpg image to u
pload
• Create an Azure cloud service
• Create an Azure SQL database
• Create an Azure storage account
• Configure to use Azure SQL database
• Configure to use Azure storage
account
• Deploy the project
Content
19
Smart Embedded System Lab Smart Embedded System Lab
Go to
http://manage.windowsazure.com/
Sign in
Deploy to Azure Create Azure Cloud service
Deploy to Azure Create Azure Cloud service
Click New -> Compute -> Cloud Service -> Quick Create
In URL box: create a unique URL prefix
Choose region
21
Smart Embedded System Lab Smart Embedded System Lab
Server informs cloud service was created
Click New -> Data Services -> SQL Database -> Quick Create
In Database Name box: use again the previous URL
In Server drop-down list, choose “New SQL Database server”
Choose the same region with the previous selection
23
Smart Embedded System Lab Smart Embedded System Lab
Create new “Login Name” and “Password”
Click on “Create SQL Database”
A SQL database is created in Azure Management Portal
25
Smart Embedded System Lab Smart Embedded System Lab
Click on the name of the created database
Click on Dashboard tab
Click on “Manage allowed IP addresses”
Under Allowed Services, click Yes
Click Save
27
Smart Embedded System Lab Smart Embedded System Lab
Click on the name of the new database
Click Manage tab -> Yes -> Yes
Click Manage tab again
Log in with the created Username
and Password
29
Smart Embedded System Lab Smart Embedded System Lab
Click New -> Data Services -> Storage -> Quick Create
Enter an URL
Location: East Asia
In REPLICATION, choose “Locally redundant”
Click Create storage account
To use Azure SQL database
In ContosoAdsWeb project open Web.Release.config31
Smart Embedded System Lab Smart Embedded System Lab
Replace comment block
By the following block
Configure the solution
<connectionStrings>
<add name="ContosoAdsContext" connectionString="{connectionstring}"
providerName="System.Data.SqlClient" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/> </connectionStrings>
In Azure Management Portal, click SQL Database Click Dashboard -> click Show connection strings
33
Smart Embedded System Lab Smart Embedded System Lab
The portal displays connection strings
In the
Web.Release.config, delete
{connectionstring} and paste the ADO.NE connection string Replace {your_password_here} with your password for the new SQL database
Save file
Copy the connection string for use in the next steps
35
Smart Embedded System Lab Smart Embedded System Lab
Right click ContosoAdsWorker -> Click Properties
Click Settings tab
Change Service Configuration to Cloud
Select ContosoAdsDbConnectionString, and past the connection string Save
37
Smart Embedded System Lab Smart Embedded System Lab
“Connection strings” for both the web role project and the worker role project are stored in environment settings in the cloud service project.
For each project, separate settings are used when the application runs locally or runs in the cloud.
Update the cloud environment setting for both web and worker role projects.
Right-click on ContosoAdsWeb project -> Properties
39
Smart Embedded System Lab Smart Embedded System Lab
Click Settings tab
In Service Configuration, choose Cloud
Open the Create Storage Account Connection String dialog box
By click on the corresponding button of StorageConnectionString41
Smart Embedded System Lab Smart Embedded System Lab
In the Create Storage Account Connection String dialog box
choose the created storage account -> OK set the Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString c
onnection string for logging
43
Smart Embedded System Lab Smart Embedded System Lab
choose the created storage account -> OK
Save changes
Setting the ContosoAdsWorker project
Right click on ContosoAdsWorker project -> Properties
45
Smart Embedded System Lab Smart Embedded System Lab
On “Service Configuration” choose Cloud
Set StorageConnectionString
47
Smart Embedded System Lab Smart Embedded System Lab
Set Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString
After configuring, the role environment settings are stored in the follo
wing files in the “ContosoAdsCloudService” project
ServiceDefinition.csdef
- Defines the setting names.
ServiceConfiguration.Cloud.cscfg
- Provides values for when the app runs in thecloud.
ServiceConfiguration.Local.cscfg
- Provides values for when the app runs locally.49
Smart Embedded System Lab Smart Embedded System Lab
Right click on the ContosoAdsCloudService project -> Publish
Click Next to sign in
51
Smart Embedded System Lab Smart Embedded System Lab
In Settings, click Next
In Summary, click Publish
53
Smart Embedded System Lab Smart Embedded System Lab
The Azure Activity Log window opens in Visual Studio.
Click the right arrow icon to expand the deployment click the Website URL to launch the application
Result of created page
Click on “Create an Ad” to add Ads
55
Smart Embedded System Lab Smart Embedded System Lab
Similarly, create an Ad
Enter data and select a .jpg image to u
pload
Edit ads
57
Smart Embedded System Lab Smart Embedded System Lab
Result
Access portal -> Storage -> Click on the created storage
Deploy the project to Azure