iT邦幫忙

第 12 屆 iThome 鐵人賽

DAY 15
1
Microsoft Azure

深入 Azure 雲端服務系列 第 12

Azure Docker - 在WSL2寫網頁打包上傳ACR建立WebAPP

WSL2 + VSCode Remote 我們可以檔案在 Linux 編輯在 Windows 10 開發程式,開發完後配上 az acr build 將專案打包到 Azure ACR Repository 上。

舉例 :

第一步 : 先下載寫好的 git 專案

git clone https://github.com/Azure-Samples/aci-helloworld.git

image

第二步 : 可以直接在 Windows 10 VSCode Terminal 下 Ubuntu Bash 命令,建立 ACR

az login
az acr create --resource-group demo --name $(uuidgen | tr -d '-')  --sku Basic

image

第三步 : 將專案藉由 az acr build 打包上傳到剛建立好的 Azure ACR

az acr build --image sample/hello-world:v1 --registry <你的ACR名稱> --file Dockerfile .

image

image

第四步 : 接著以 ACR 的 Respository 創建 Azure Web App By Docker

az appservice plan create -n appserviceDemoPlan -g demo --is-linux
az webapp create -n <Web App 名稱> -g demo -p appserviceDemoPlan -i <你的ACR圖片路徑>

整個流程藉由 WSL2 + VSCode + Azure CLI 跑下來非常方便、快速。

備註 : 假如跟筆者一樣使用 Ubuntu 20.04 會遇到缺少套件情況,要自己換成先行版本,可以看 issue : No module issue on Ubuntu 20.04(Focal)/WSL · Issue #14011 · Azure/azure-cli

image

解決命令 :

sudo apt remove azure-cli -y && sudo apt autoremove -y # 卸載 
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash # 安裝測試版

image


上一篇
Azure Docker - 使用 WSL2 管理/開發 Azure 資源
下一篇
Azure Retail Prices REST API 分析全 Azure 服務價格差異 - JSON 轉 Excel版本
系列文
深入 Azure 雲端服務15
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言