์ด repo๋ 2016๋ 9์ ์์ ๋ Azure dev camp 2์ผ์ฐจ PaaS ๊ณผ์ ์ ๋ํ ์ฝ๋์ hands on ์๋ฃ๋ฅผ ์ ๊ณต
-
Azure Portal์ ๋ก๊ทธ์จ ํ ๋ฆฌ์์ค ๊ทธ๋ฃน์ ์์ฑ
https://azure.microsoft.com/en-us/documentation/articles/resource-group-portal/ -
Web App์ ์์ฑ
https://azure.microsoft.com/en-us/documentation/articles/app-service-web-get-started/
- ์์ฑํ Web App์์ FTP, Git, Github ๋ฑ์ผ๋ก ๋ฐฐํฌ
FTP : https://azure.microsoft.com/en-us/documentation/articles/web-sites-deploy/
Git : https://azure.microsoft.com/en-us/documentation/articles/app-service-deploy-local-git/
git init
git add .
git commit -m "initial commit"
git remote add azure [URL for remote repository]
git push azure master
//์ฝ๋ ์์ ์์
ํ
git add .
git commit -m "second commit"
git push azure master
//๋ฐฐํฌ ํ์ธ
Github : https://azure.microsoft.com/en-us/documentation/articles/app-service-web-arm-from-github-provision/
repo๋ฅผ github์ ์์ฑ
Azure portal์์ ์ฐ์ ๋ฐฐํฌ ์ค์
์ค์ ํ github์ repo๋ฅผ Azure Portal์์ ์ง์
- Web App๊ณผ C# - ASP.NET https://azure.microsoft.com/en-us/documentation/articles/web-sites-dotnet-get-started/
VS์์ ASP.NET ํ๋ก์ ํธ ์์ฑ
๋น๋, ๋๋ฒ๊ทธ, ์คํ
์์ฑ๋ Project๋ฅผ VS์์ ๊ฒ์ ์ํ
- Web App๊ณผ PHP
https://azure.microsoft.com/en-us/documentation/articles/app-service-web-php-get-started/
index.php ์์ฑ
phpinfo() ์ฝ๋ ์ถ๊ฐ
WebMatrix ๋๋ git์ ์ด์ฉํด publish ์ํ
Web App ์ค์ ์์ php version ๋ฐ php ๊ด๋ จ cofnig ์ํ
- Web App๊ณผ node.js
https://azure.microsoft.com/en-us/documentation/articles/app-service-web-nodejs-get-started/
app.js ์์ฑ
console.log ์ฝ๋ ์ถ๊ฐ
git ๋ฑ์ ์ด์ฉํด publish ์ํ
- Web App๊ณผ Python
https://azure.microsoft.com/en-us/documentation/articles/web-sites-python-ptvs-django-mysql/
//todo
- Web App๊ณผ Java
https://azure.microsoft.com/en-us/documentation/articles/web-sites-java-get-started/
//todo
๋ฐฑ๊ทธ๋ผ์ด๋์์ ์ํ๋๋ ์์
์ WebJob ์ผ๋ก ์คํ
https://azure.microsoft.com/en-us/documentation/articles/web-sites-create-web-jobs/
// http://requestb.in/ ์ฌ์ดํธ๋ฅผ ์ด์ฉํด webjob์ inpection
// req.php ํ์ผ ์์ฑ
<?php
$result = file_get_contents('http://requestb.in/๊ฒฝ๋ก');
echo $result;
?>
// settings.job ํ์ผ ์์ฑ
{
"schedule": "0 */2 * * * *"
}
// ๋ ํ์ผ์ zip์ผ๋ก ๋ฌถ์ ํ webjob์ผ๋ก ์
๋ก๋
Deploy WebJobs using Visual Studio
https://azure.microsoft.com/en-us/documentation/articles/websites-dotnet-deploy-webjobs/
// demo\webjob-cs-with-webapp ํ๋ก์ ํธ ์ฐธ์กฐ
// console ํ๋ก์ ํธ ๋๋ Azure WebJob ํ๋ก์ ํธ ํ
ํ๋ฆฟ์ผ๋ก ํ๋ก์ ํธ ์์ฑ
// ASP.NET web project ์์ฑ ํ ์ถ๊ฐ๋ก console project ์์ฑ
// console project์์ reqeustb.in์ ์ด์ฉํด ์์ฒญ ํ
์คํธ
// Web rpoject์์ console ํ๋ก์ ํธ๋ฅผ webjob์ผ๋ก ์ถ๊ฐ
// Web App ๋ฐฐํฌ ์ํ
Web App ํฌ๊ธฐ์กฐ์
https://azure.microsoft.com/en-us/documentation/articles/web-sites-scale/
// Web App์ App Service Plan๊ณผ ํฌ๊ธฐ์กฐ์
์ฐธ๊ณ ์ ๋ณด : Pattern & Practice - Transient Fault Handling
https://msdn.microsoft.com/en-us/library/dn440719(v=pandp.60).aspx
Azure Storage ๊ฐ๋ฐ์ ์ ์ฉํ Storage Explorer ๋๊ตฌ ๋ค์ด๋ก๋ http://storageexplorer.com/
Storage Exploerer ์ค์น ํ Azure Portal์์ ์ ์ฅ์ ๊ณ์ (Storage Account)์ ์์ธ์ค ํค - ์ฐ๊ฒฐ๋ฌธ์์ด์ ๋ฃ์ผ๋ฉด ํด๋น ์ ์ฅ์ ๊ณ์ ์ Storage Explorer๋ก ๋ฐ๋ก ์ ๊ทผ ๊ฐ๋ฅํฉ๋๋ค.
์ฐธ๊ณ ๋งํฌ : https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-blobs/
public static void CreateContainer()
{
// ์ ์ฅ์ ์ฐ๊ฒฐ ๋ฌธ์์ด ์ฒ๋ฆฌ
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
CloudConfigurationManager.GetSetting("StorageConnectionString"));
// client ๊ฐ์ฒด ์์ฑ
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// ์ปจํ
์ด๋ ๊ฐ์ฒด ์ฐธ์กฐ
CloudBlobContainer container = blobClient.GetContainerReference("mycontainer");
// ์ปจํ
์ด๋๊ฐ ์์ผ๋ฉด ์์ฑ
container.CreateIfNotExists();
return;
}
// ์๋ ๋งํฌ์์ ์ ๋ณด ํ์ธ https://azure.microsoft.com/en-us/documentation/articles/storage-nodejs-how-to-use-blob-storage/
// ์ค์น
// npm install azure-storage
// ํจํค์ง import ์ํ
var azure = require('azure-storage');
// connection string ์์
// environment variable์ ๊ตฌ์ฑ | Azure ์์์ ๊ตฌ์ฑ๋ ๊ฐ๋ฅ
var tableService = azure.createTableService('<์ ์ฅ์์ด๋ฆ>', '<์ ์ฅ์ํค>');
// ํ
์ด๋ธ ์์ฑ
tableService.createTableIfNotExists('nodetable', function(error, result, response) {
if (!error) {
// ์ํ์๋ฃ
console.log('ok');
console.log(response);
} else {
console.log(error);
}
});
<?php
// composer๋ฅผ ์ด์ฉํด PHP Azure client๋ฅผ ์ค์น
// https://azure.microsoft.com/en-us/documentation/articles/storage-php-how-to-use-blobs/
require_once 'vendor\autoload.php';
use WindowsAzure\Common\ServicesBuilder;
use WindowsAzure\Blob\Models\CreateContainerOptions;
use WindowsAzure\Blob\Models\PublicAccessType;
use WindowsAzure\Common\ServiceException;
// https://azure.microsoft.com/en-us/documentation/articles/storage-php-how-to-use-blobs/
// Storage์ connection string ์ ๊ณต
$connectionString = "DefaultEndpointsProtocol=http;AccountName=<์ ์ฅ์์ด๋ฆ>;AccountKey=<์ ์ฅ์ํค>";
// REST proxy ์์ฑ
$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
$createContainerOptions = new CreateContainerOptions();
//setPublicAccess ์ ๊ทผ ์ ์ฑ
์ค์
// CONTAINER_AND_BLOBS:
// ์ ์ฒด ์์ธ์ค ๊ถํ
//
// BLOBS_ONLY:
// blob๋ค์ ๋ํด์๋ง ์ฝ๊ธฐ ๊ถํ.
$createContainerOptions->setPublicAccess(PublicAccessType::CONTAINER_AND_BLOBS);
// ์ปจํ
์ด๋ ๋ฉํ๋ฐ์ดํฐ ์ค์
$createContainerOptions->addMetaData("VSTechUp", "Visual Studio");
$createContainerOptions->addMetaData("Azure", "Cloud");
try {
// ์ปจํ
์ด๋ ์์ฑ
$blobRestProxy->createContainer("phpcontainer", $createContainerOptions);
}
catch(ServiceException $e){
// ์๋ฌ ํธ๋ค๋ง
$code = $e->getCode();
$error_message = $e->getMessage();
echo $code.": ".$error_message."<br />";
}
?>
์ฐธ๊ณ ๋งํฌ : https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-tables/
// ์ ์ฅ์ ์ฐ๊ฒฐ ๋ฌธ์์ด ์ฒ๋ฆฌ
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
CloudConfigurationManager.GetSetting("StorageConnectionString"));
// table ํด๋ผ์ด์ธํธ ๊ฐ์ฒด ์์ฑ
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
// ํ
์ด๋ธ ์ฐธ์กฐ ์ค์
CloudTable table = tableClient.GetTableReference("people");
// ํ
์ด๋ธ์ด ์กด์ฌํ์ง ์์ผ๋ฉด ์์ฑ
table.CreateIfNotExists();
// ์๋ ๋งํฌ์์ ์ ๋ณด ํ์ธ https://azure.microsoft.com/en-us/documentation/articles/storage-nodejs-how-to-use-blob-storage/
// ์ค์น
// npm install azure-storage
// ํจํค์ง import ์ํ
var azure = require('azure-storage');
// connection string ์์
// environment variable์ ๊ตฌ์ฑ | Azure ์์์ ๊ตฌ์ฑ๋ ๊ฐ๋ฅ
var tableService = azure.createTableService('<์ ์ฅ์๊ณ์ >', '<์ ์ฅ์ํค>');
// ํ
์ด๋ธ ์์ฑ
tableService.createTableIfNotExists('nodetable', function(error, result, response) {
if (!error) {
// ์ํ์๋ฃ
console.log('ok');
console.log(response);
} else {
console.log(error);
}
});
<?php
// https://azure.microsoft.com/en-us/documentation/articles/storage-php-how-to-use-table-storage/
require_once 'vendor\autoload.php';
//ini_set('display_errors', 1);
//error_reporting(~0);
use WindowsAzure\Common\ServicesBuilder;
use WindowsAzure\Common\ServiceException;
// Storage์ connection string ์ ๊ณต
$connectionString = "DefaultEndpointsProtocol=http;AccountName=<์ ์ฅ์๊ณ์ >;AccountKey=<์ด์นด์ดํธํค>";
// Azure์ table storage๋ฅผ ์ํ REST proxy ์์ฑ
$tableRestProxy = ServicesBuilder::getInstance()->createTableService($connectionString);
/////////////////////////////////////////////////////////////////
// 01 ํ
์ด๋ธ ์์ฑ
/////////////////////////////////////////////////////////////////
try {
// ํ
์ด๋ธ ์์ฑ
$tableRestProxy->createTable("phptable");
}
catch(ServiceException $e){
$code = $e->getCode();
$error_message = $e->getMessage();
echo $code.": ".$error_message."<br />";
}
?>
https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-queues/
public static void CreateQueue()
{
// ์ฐ๊ฒฐ ๋ฌธ์์ด ์ฒ๋ฆฌ
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
CloudConfigurationManager.GetSetting("StorageConnectionString"));
// ํ ํด๋ผ์ด์ธํธ ๊ฐ์ฒด ์์ฑ
CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
// ํ ์ฐธ์กฐ ์ค์
CloudQueue queue = queueClient.GetQueueReference("myqueue");
// ํ๊ฐ ์์ผ๋ฉด ์์ฑ
queue.CreateIfNotExists();
}
https://azure.microsoft.com/en-us/documentation/articles/storage-nodejs-how-to-use-queues/
todo
https://azure.microsoft.com/en-us/documentation/articles/storage-php-how-to-use-queues/
todo
์ฐธ๊ณ ๋งํฌ : https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-files/
์ฃผ์์ฌํญ์ผ๋ก, outbound 445 ๊ฐ ์ด๋ ค ์์ด์ผ ํ๋ ์ ํ์ด ์์ผ๋ฉฐ, ISP์ ๋ฐ๋ผ์ ๋ค๋ฆ.
์๊ฐ ๋ฐ ์์ฑ
VS ๋๋ SSMS์์ ์ฐ๊ฒฐ
SQL Database vs VM
์ฐธ๊ณ ๋งํฌ : https://msdn.microsoft.com/library/mt718320.aspx
using System;
using C = System.Data.SqlClient;
namespace azure_sql_cs
{
class Program
{
static void Main(string[] args)
{
using (var connection = new C.SqlConnection(
"Server=tcp:์๋ฒ๋ช
.database.windows.net,1433;Initial Catalog=DB๋ช
;Persist Security Info=False;User ID=์ ์ ์์ด๋;Password=๋น๋ฐ๋ฒํธ;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
)) // ์ฐ๊ฒฐ ๋ฌธ์์ด์ ๋ณต์ฌํ๊ณ Azure SQL Database ์์ฑ์ ์ง์ ํ user id์ pwd๋ก ๋ณ๊ฒฝ. ์๋ฒ๋ช
๊ณผ DB๋ช
์ ์๋์ผ๋ก ์ฐ๊ฒฐ ๋ฌธ์์ด์ ์ง์
{
connection.Open();
Console.WriteLine("Connected successfully.");
Console.WriteLine("Press any key to finish...");
Console.ReadKey(true);
}
}
}
}
์ฐธ๊ณ ๋งํฌ : https://msdn.microsoft.com/library/mt720665.aspx
<?php
function OpenConnection()
{
try
{
$serverName = "tcp:์๋ฒ๋ช
.database.windows.net,1433";
$connectionOptions = array("Database"=>"DB๋ช
",
"Uid"=>"์ ์ ์์ด๋", "PWD"=>"๋น๋ฐ๋ฒํธ");
$conn = sqlsrv_connect($serverName, $connectionOptions);
if($conn == false)
die(FormatErrors(sqlsrv_errors()));
}
catch(Exception $e)
{
echo("Error!");
}
}
?>
์ฐธ๊ณ ๋งํฌ :
https://msdn.microsoft.com/library/mt715784.aspx
https://msdn.microsoft.com/library/mt652094.aspx
npm install tedious
var Connection = require('tedious').Connection;
var config = {
userName: 'yourusername',
password: 'yourpassword',
server: 'yourserver.database.windows.net',
// If you are on Microsoft Azure, you need this:
options: {encrypt: true, database: 'AdventureWorks'}
};
var connection = new Connection(config);
connection.on('connect', function(err) {
// If no error, then good to proceed.
console.log("Connected");
});
- Elastic Pool
- OSS์์ ์ฐ๊ฒฐ : https://azure.microsoft.com/en-us/documentation/articles/sql-database-libraries/
์๊ฐ
NoSQL tutorial: Build a DocumentDB C# console application
https://azure.microsoft.com/en-us/documentation/articles/documentdb-get-started-quickstart/
์ฐธ๊ณ ๋งํฌ : https://azure.microsoft.com/en-us/documentation/articles/documentdb-get-started-quickstart/#quickstart
// app.config ํ์ผ์ ๋ด์ฉ์ key ๊ฐ์ ์์ฑํ documentdb์ ์ ๋ณด๋ก ์์
...
<appSettings>
<add key="EndpointUri" value="์๋ํฌ์ธํธURI๋ก๋ณ๊ฒฝ" />
<add key="PrimaryKey" value="ํ๋ผ์ด๋จธ๋ฆฌํค๋ก ๋ณ๊ฒฝ" />
</appSettings>
...
์ฐธ๊ณ ๋งํฌ : https://azure.microsoft.com/en-us/documentation/articles/documentdb-nodejs-get-started/
npm install
// config.js ํ์ผ์ ์ ๋ณด๋ฅผ ์์
...
config.endpoint = "์๋ํฌ์ธํธURI";
config.primaryKey = "ํ๋ผ์ด๋จธ๋ฆฌํค";
...
์ดํ ์ฝ๋๋ฅผ ์คํํ๋ฉด console์ documentdb์ ์์ ๋ด์ฉ์ source ํ๋ฆ๋๋ก ์ฒ๋ฆฌ
์๊ฐ
Hadoop tutorial: Get started using Hadoop in HDInsight on Windows
https://azure.microsoft.com/en-us/documentation/articles/hdinsight-hadoop-tutorial-get-started-windows/
Hadoop tutorial: Get started using Linux-based Hadoop in HDInsight
https://azure.microsoft.com/en-us/documentation/articles/hdinsight-hadoop-linux-tutorial-get-started/
Azure Machine Learning ์ฐธ๊ณ ๋งํฌ : https://azure.microsoft.com/en-us/documentation/services/machine-learning/
๊ธฐ๋ณธ ์ ๊ณต๋๋ Adult census income ๋ฐ์ดํฐ๋ฅผ ์ด์ฉํด classification ML์ ์ํํ๋ ๋ชจ๋ธ ์์ฑ
ํ์ํ property๋ฅผ ์ ์ ํด traning ์ํค๊ณ ๊ฒฐ๊ณผ๋ฅผ ๋์ถ
๋
ธ์ถ๋ ML API๋ฅผ C#์ฝ๋, R ๋๋ Python์ผ๋ก ํ์ฉํ๋ ๋ฐฉ๋ฒ
C#, node.js + (Python) ์ ์ด์ฉํ Azure Machine Learning API ๋ฐ๋ชจ ์ฝ๋
์ด Repository๋ ๋ชจ๊ฐ์ฝx๋ชจ๋ ์ํ๋ฒ์งธ ๋ชจ์ ๋ฐํ์ ์ฌ์ฉ๋ demo ์ฝ๋. https://github.com/CloudBreadPaPa/mogakko-9th
ml-demo\cs ํด๋์์ ํ๋ก์ ํธ ์คํ ์ฝ๋์ API KKey๋ฅผ ์์ ์ Azure ML API Key๋ก ์์
...
const string apiKey = "API Key"; // Azure ML์ด ์ ๊ณตํ๋ API Key
...
client.BaseAddress = new Uri("Azure ML์ด ์ ๊ณตํ๋ API URL");
...
ml-demo\node\app.js ํ์ผ์ API Key๋ฅผ ์์ ์ API Key๋ก ์์
...
var host = 'asiasoutheast.services.azureml.net' //์ ๊ณตํ๋ HOST ๊ฒฝ๋ก
var path = 'HOST ์ดํ URL Path ์ ๋ณด'
...
var api_key = 'API Key ์ ๋ณด'
...
node.js๋ก Azure ML์ call ์์ ๋งํฌ : https://blogs.msdn.microsoft.com/bigdatasupport/2016/02/18/how-to-call-a-azure-machine-learning-web-service-from-nodejs/
node reqeust package๋ฅผ ์ด์ฉํ๋ฉด ๋ ์ฝ๊ฒ node์์ Azure ML์ ํธ์ถ ๊ฐ๋ฅํ ๊ฒ์ผ๋ก ์์๋จ. ์ฐธ๊ณ ๋งํฌ : https://github.com/request/request
Python์ ํธ์ถํ๊ธฐ ์ํ ๋ฐ๋ชจ ๊ธฐ๋ณธ code๋ Python 2.7.x ๊ธฐ์ค. ์๋ ์ฝ๋ ๋ฐ๋ชจ๋ ์๋ง๋ ํ๊ธ๋ก ์ธํด unicode ์ฒ๋ฆฌ๊ฐ ํ์ํ ์ ์์.
import urllib2
# If you are using Python 3+, import urllib instead of urllib2
import json
data = {
"Inputs": {
"input1":
{
"ColumnNames": ["idx", "๋์ด", "ํ๋ก๋ชจ์
์ฐธ์ฌ์", "์๋ณ์", "์ผํ๊ท ๊ฒ์ํ๋ ์ด๋ถ", "90์ผ๋ด์์ดํ
๊ตฌ๋งค์", "๊ฒ์๋ ๋ฒจ๋ฒ์", "๋ณด์ ํฌ๋ฆฌ์คํ", "์ ์
๊ฒฝ๋ก", "์ธ์ข
", "์ฑ๋ณ", "๊ฐ์
์ฝ๋", "๊ตฌ๋งค๋ฒํธ", "์ฃผ๋น์ ์์", "๊ฐ์
๊ตญ๊ฐ", "์ดํ์ฌ๋ถ"],
"Values": [ [ "0", "0", "0", "0", "0", "0", "0", "0", "value", "value", "value", "0", "0", "0", "value", "value" ], [ "0", "0", "0", "0", "0", "0", "0", "0", "value", "value", "value", "0", "0", "0", "value", "value" ], ]
}, },
"GlobalParameters": {
}
}
body = str.encode(json.dumps(data))
url = 'AzureML์ด ์ ๊ณตํ๋ URL'
api_key = 'AzureML์ด ์ ๊ณตํ๋ APIKey' # Replace this with the API key for the web service
headers = {'Content-Type':'application/json', 'Authorization':('Bearer '+ api_key)}
req = urllib2.Request(url, body, headers)
try:
response = urllib2.urlopen(req)
# If you are using Python 3+, replace urllib2 with urllib.request in the above code:
# req = urllib.request.Request(url, body, headers)
# response = urllib.request.urlopen(req)
result = response.read()
print(result)
except urllib2.HTTPError, error:
print("The request failed with status code: " + str(error.code))
# Print the headers - they include the requert ID and the timestamp, which are useful for debugging the failure
print(error.info())
print(json.loads(error.read()))
๋ง์ฐฌ๊ฐ์ง๋ก, API Key ๋ณ์๋ฅผ ์์ ์ Key๋ก ๋ณ๊ฒฝํ๊ณ ์ํ ํด์ผ ํจ.
...
url = 'AzureML์ด ์ ๊ณตํ๋ URL'
api_key = 'AzureML์ด ์ ๊ณตํ๋ APIKey' # Replace this with the API key for the web service
...
์ด๋ถ๋ถ์ ๋ณ๊ฒฝํ๊ณ ์ํ
๋ฌธ์์ ๋