Azure๋กœ ๊ฐ„๋‹จํ•œ ์›น์•ฑ ๋งŒ๋“ค๊ธฐ

2022. 6. 26. 18:16ใ†Azure

<ํŠœํ† ๋ฆฌ์–ผ ๋งํฌ>

https://docs.microsoft.com/en-us/learn/modules/host-a-web-app-with-azure-app-service/

 

Host a web application with Azure App Service - Learn

Create a website using C#, Java, Python or Node.js and deploy it through the hosted web app platform in Azure App Service.

docs.microsoft.com

 

0. ์‹œ์ž‘ํ•˜๊ธฐ ์ „์— ํ•™์ƒ ๊ณ„์ •์œผ๋กœ $100 ํฌ๋ ˆ๋”ง ๋ฐ›๊ธฐ

Azure๋กœ ๋“ค์–ด๊ฐ€๋ณด๋‹ˆ AWS์™€ ๋‹ค๋ฅด๊ฒŒ ํ•™์ƒ์ด๋ฉด ์ถ”๊ฐ€์ ์ธ ํ˜œํƒ์ด ์žˆ๋Š” ๊ฒƒ ๊ฐ™์•˜๋‹ค. ๋‚˜๋Š” ์• ์ดˆ์— ํ•™๊ต ์ด๋ฉ”์ผ๋กœ ๊ฐ€์ž…ํ•ด ๋‘” ๊ณ„์ •๋„ ์žˆ์—ˆ๊ณ , (์ด๊ฒƒ ๋•Œ๋ฌธ์ธ์ง€๋Š” ์ž˜ ๋ชจ๋ฅด๊ฒ ์ง€๋งŒ) ํ•™๊ต์—์„œ ์˜ˆ์ „์— Microsoft Learn ์—ฐ๋™ ํ˜œํƒ? ๊ฐ™์€๊ฒŒ ์žˆ์—ˆ์–ด์„œ ๋ฌธ์ž ์ธ์ฆ ํ›„, ๊ฐœ์ธ์ •๋ณด๋ฅผ ๊ธฐ์ž…ํ•˜๋‹ˆ ์ด๋ ‡๊ฒŒ ํฌ๋ ˆ๋”ง์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค. ํ•™์ƒ์ด๋ผ๋ฉด ๋‹ค๋“ค ๋ฐ›๊ณ  ์‹œ์ž‘ํ•˜์‹œ๋Š”๊ฒŒ..

 

 

2๋ฒˆ์งธ ๋‹ค์‹œ ๋ณด๊ธฐ, ์ •๋ฆฌํ•˜๊ธฐ

 

1. ๋ฆฌ์†Œ์Šค ๋ฉ”๋‰ด์—์„œ ์›น์•ฑ ๋งŒ๋“ค๊ธฐ

 

์—ฌ๊ธฐ์„œ ๋ฆฌ์†Œ์Šค ๋งŒ๋“ค๊ธฐ ํด๋ฆญ

 

 

2. ์›น์•ฑ ๋งŒ๋“ค๊ธฐ ์„ค์ •

- What is ๋ฆฌ์†Œ์Šค ๊ทธ๋ฃน?

๋”๋ณด๊ธฐ

Everything you create on Azure is a resource -> Azure์—์„œ ๋งŒ๋“ค์–ด์ง€๋Š” ๋ชจ๋“  ๊ฒƒ์„ '๋ฆฌ์†Œ์Šค'๋ผ๊ณ  ํ•˜๊ณ , ๋ฆฌ์†Œ์Šค๋ฅผ ๊ด€๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด ๋ฌถ๋Š” ๊ทธ๋ฃน. AWS๋กœ ์ƒ๊ฐํ•ด๋ณด๋ฉด.. ๋ญ๊ฐ€ ์žˆ์„๊นŒ?

 

๊ตฌ๋…์€ Azure for Students.

ํŠœํ† ๋ฆฌ์–ผ์—๋Š” ๋ฆฌ์†Œ์Šค ๊ทธ๋ฃน์„ ์„ ํƒํ•˜๋ผ๊ณ  ๋˜์–ด ์žˆ์—ˆ๋Š”๋ฐ, ์ •์ž‘ ์„ ํƒ์ง€์—๋Š” ์•„๋ฌด๊ฒƒ๋„ ์—†์—ˆ๊ธฐ ๋•Œ๋ฌธ์— 'CloudClub'์ด๋ผ๋Š” ์ด๋ฆ„์œผ๋กœ ๊ทธ๋ฃน์„ ์ƒˆ๋กœ ์ƒ์„ฑํ–ˆ๋‹ค.

 

 

๊ทธ๋ฃน ์ด๋ฆ„๋งŒ ์ž…๋ ฅํ•˜๋ฉด ๋๊ณ , ๋”ฐ๋กœ ์„ค์ •ํ•  ๊ฒƒ์€ ์—†์—ˆ๋‹ค. 

 

 

์ธ์Šคํ„ด์Šค ์ •๋ณด๋ฅผ ์ž…๋ ฅํ• ๋•Œ ์ด๋ฆ„์€ Azure๋‚ด์—์„œ ํŠน์ˆ˜ํ•ด์•ผ ํ•œ๋‹ค.

Docker ๋ฅผ ์ž˜ ๋ชฐ๋ผ์„œ ์ฝ”๋“œ ๋ฐฐํฌ๋ฅผ ์„ ํƒํ–ˆ๊ณ , ๋Ÿฐํƒ€์ž„ ์Šคํƒ์€ ๋‹น๊ทผ Python, ์ง€์—ญ์€ ํ•œ๊ตญ

 

 

App Service ์š”๊ธˆ์ œ๊ฐ€ ๋ฐฉ๊ธˆ ์ž…๋ ฅํ•œ ๋ฆฌ์†Œ์Šค ๊ทธ๋ฃน ์ด๋ฆ„์— ๋งž์ถฐ์„œ ์ž๋™์œผ๋กœ ์ƒ์„ฑ๋˜์—ˆ๋‹ค. 

๊ทธ๋ฆฌ๊ณ  Sku ๋ฐ ํฌ๊ธฐ๋ฅผ ๊ผญ ๋ณ€๊ฒฝํ•˜์ž. ๊ธฐ๋ณธ B1์€ ์ฒซ๋‹ฌ๋งŒ ๋ฌด๋ฃŒ์ด๊ณ , ์š”๊ธˆ์ด ์ฒญ๊ตฌ๋˜๋Š” ๋ฐฉ์‹์ด๋‹ˆ F1์œผ๋กœ ๋ณ€๊ฒฝํ•˜๋ฉด ๋œ๋‹ค.

 

๋ณ€๊ฒฝ ๋

 

๊ทธ๋Ÿผ ์ด์ œ ๊ฒ€ํ†  + ๋งŒ๋“ค๊ธฐ~

์ตœ์ข…์ ์œผ๋กœ '๋งŒ๋“ค๊ธฐ'๊นŒ์ง€ ๋ˆŒ๋ €์„๋•Œ ์ƒ๊ฐ๋ณด๋‹ค ๋ฐฐํฌ์— ์‹œ๊ฐ„์ด ๊ฝค ์˜ค๋ž˜ ๊ฑธ๋ ธ๋‹ค.(1๋ถ„ ์ •๋„)

 

<๋””ํดํŠธ ์›น์•ฑ ํ™•์ธ>

 

 

๋งํฌ๋ฅผ ํด๋ฆญํ•ด๋ณด๋ฉด

์ด๋Ÿฐ ํ™”๋ฉด์„ ๋งŒ๋‚  ์ˆ˜ ์žˆ๋‹ค.

 

3. ์›น์•ฑ ์ฝ”๋“œ ์ž‘์„ฑํ•˜๊ธฐ

Microsoft Learn์—์„œ๋Š” Flask์œผ๋กœ ์ •๋ง ๊ฐ„๋‹จํ•œ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๊ณ  Github์— ์ƒˆ ๋ ˆํฌ๋ฅผ ๋งŒ๋“ค๊ณ  ์ปค๋ฐ‹ํ•˜๋Š” ํ˜•์‹์œผ๋กœ ์ง„ํ–‰ํ–ˆ์ง€๋งŒ, ๋‚˜๋Š” ์ด๋ฏธ ๊ธฐ์กด์— ๋งŒ๋“ค์–ด๋‘” ์ƒ˜ํ”Œ ์›น์•ฑ ๋ ˆํฌ๋“ค์ด ์žˆ์–ด์„œ ๊ทธ๊ฑธ๋กœ ๋Œ€์ฒดํ•˜๊ธฐ๋กœ ํ–ˆ๋‹ค.

 

4. CLI ์ด์šฉํ•ด์„œ ์ฝ”๋“œ ์ž‘์„ฑํ•˜๊ธฐ

ํŠœํ† ๋ฆฌ์–ผ์—์„œ ์ž๋™์œผ๋กœ Azure Cloud Shell์— ์—ฐ๊ฒฐ์„ ํ•ด์คฌ๋‹ค. ์˜ค์˜น~

AWS๋กœ๋„ ํ•ญ์ƒ ์›น์œผ๋กœ๋งŒ ํ•ด๋ดค๊ณ , CLI๋Š” ์•ˆ ์จ๋ด์„œ ์ด๋ฒˆ์—๋Š” ์–ด๋–ป๊ฒŒ ์ž‘๋™ํ•˜๋‚˜ ํŠœํ† ๋ฆฌ์–ผ์„ ๋”ฐ๋ผํ•ด๋ดค๋‹ค.

์‹ ๊ธฐ๋ฐฉ๊ธฐ..

 

5. ์ฝ”๋“œ ๋ฐฐํฌํ•˜๋Š” ๋‹ค์–‘ํ•œ ๋ฐฉ๋ฒ•

1) ์ž๋™

  • Azure DevOps
  • GitHub
  • Bitbucket
  • OneDrive
  • Dropbox 

2) ์ˆ˜๋™

  • Git
  • az webapp up
export APPNAME=$(az webapp list --query [0].name --output tsv)
export APPRG=$(az webapp list --query [0].resourceGroup --output tsv)
export APPPLAN=$(az appservice plan list --query [0].name --output tsv)
export APPSKU=$(az appservice plan list --query [0].sku.name --output tsv)
export APPLOCATION=$(az appservice plan list --query [0].location --output tsv)

์ด ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด์„œ ์•„๊นŒ Azure Portal์—์„œ ๋งŒ๋“ค์–ด๋‘” ์›น ์•ฑ์˜ ์ •๋ณด๋ฅผ ์ฐพ๋Š”๋‹ค.

๊ทธ ๋’ค์— ์•„๊นŒ ๋งŒ๋“ค์–ด ๋‘์—ˆ๋˜ ๋””๋ ‰ํ† ๋ฆฌ๋กœ ๋“ค์–ด๊ฐ€์„œ az webapp up --name $APPNAME --resource-group $APPRG --plan $APPPLAN --sku $APPSKU --location "$APPLOCATION

์„ ํ•ด์คฌ๋Š”๋ฐ.. ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒ

 

export -p ๋ช…๋ น์–ด๋กœ ์ฐพ์•„๋ณด๋‹ˆ๊นŒ location, name, plan ๋“ฑ์„ ๋ชจ๋‘ ๊ฐ€์ ธ์˜ค์ง€ ๋ชปํ–ˆ์Œ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค.

 

์—ฌ๋Ÿฌ๊ฐ€์ง€๋ฅผ ์‹œ๋„ํ•ด๋ณด๊ณ  az webapp ๋ช…๋ น์–ด๋กœ ์ฒดํฌ๋ฅผ ํ•ด๋ดค๋Š”๋ฐ๋„ ๋นˆ ๋ฐฐ์—ด์„ ๋ฆฌํ„ด ๋ฐ›์•˜๋‹ค.

 

 

์Œ.. ์—ฐ๊ฒฐ์ด ์•ˆ๋œ๊ฑธ๊นŒ..? (๊ฐ™์ด ํ•ด๊ฒฐ.. ์‹œ๋ฌด๋ฃฉ)

 

  • ZIP ํŒŒ์ผ๋กœ ๋ฐฐํฌ: az webapp deployment source config-zip

 

6. VSCode๋กœ ๋ฐฐํฌํ•˜๊ธฐ

<์ฐธ๊ณ  ๋งํฌ>

https://docs.microsoft.com/en-us/azure/app-service/quickstart-python?tabs=flask%2Cwindows%2Cvscode-aztools%2Cterminal-bash%2Clocal-git-deploy%2Cdeploy-instructions-azportal%2Cdeploy-instructions-zip-azcli

 

Quickstart: Deploy a Python (Django or Flask) web app to Azure - Azure App Service

Get started with Azure App Service by deploying your first Python app to Azure App Service.

docs.microsoft.com

Azure App Service extension์„ ์„ค์น˜ํ•ด์ฃผ๋ฉด ์™ผ์ชฝ์— Azure ์•„์ด์ฝ˜์ด ์ƒ๊ธด๋‹ค.

 

 

๊ทธ๋Ÿผ ์ด์ œ ์—ฌ๊ธฐ์„œ workspace ์˜†์— ์žˆ๋Š” ์—…๋กœ๋“œ ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด

 

 

์ด๋ ‡๊ฒŒ ์ž‘์„ฑํ•œ ์ฝ”๋“œ๋ฅผ ๋ฐ”๋กœ deployํ•  ์ˆ˜ ์žˆ๋‹ค.

 

 

์•„๊นŒ ๋งŒ๋“ค์–ด๋‘” cloudclub-webapp์ด ์ž˜ ๋œฌ๋‹ค.

 

 

์ด๋Ÿฐ ํ™”๋ฉด์ด ๋œจ๋ฉด ์ž˜ ๋œ ๊ฒƒ.. 

deploy๊ฐ€ ๋‹ค ๋œ ํ›„์—๋Š” ์กฐ๊ธˆ ๊ธฐ๋‹ค๋ ค์•ผ ์ฝ˜ํ…์ธ ๊ฐ€ ๋กœ๋“œ๋œ๋‹ค.(์ด๋Ÿฐ ๋ถ€๋ถ„์€ AWS๊ฐ€ ํ›จ์”ฌ ๋น ๋ฅธ ๊ฒƒ ๊ฐ™์Œ)

 

 

์ž˜ ๋ฐฐํฌ๋˜์—ˆ๋‹ค.

 

Github์œผ๋กœ ์—ฐ๋™ํ•˜๋Š”๊ฒƒ๋„ ํ•˜๋ฉด ์ข‹์„ํ…๋ฐ ์‹œ๊ฐ„์ด ์—†์–ด์„œ ํŒจ์Šค.. CLI ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๋ฉด ์ข‹๊ฒ ๋‹ค..๋Š” ๋งˆ์Œ

'Azure' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

Azure Kubernetes  (0) 2022.07.04