åºæ¬çã«ã¯ Windows 㨠Visual Studio ã使ã£ã¦ Azure Functions ã GitHub ã§å ¬éãã¦ããã¢ããªã±ã¼ã·ã§ã³ã¨ã©ã¤ãã©ãªãæ¸ãã¦ãã¾ãããæè¿ã¯ Python ã Go ãæ¸ãå¿ è¦ãã¡ããã¡ããåºã¦ããã®ã§ãè²ã ã¨è¦³å¿µã㦠WSL 2 ã®ç°å¢ãæ§ç¯ãã¦ä½¿ã£ã¦ãã¾ãã
ç¹ã« Python 㯠Azure Functions ã 㨠Linux ã®ã¿å¯¾å¿ã¨ãªãã®ã§ãWindows ä¸ã§ã®éçºã¯é£ãããªã£ã¦ãã¾ããä»ã«ãå人çã« PR ãæãã¦ãã Terraform Provider for Azure ã Windows ä¸ã§ã¯ä¸é¨ã®ãã¹ããéããªããªã£ã¦ããã®ã§ãWSL 2 ã使ããªãã¨é£ããç¶æ³ã§ãã
ç°å¢æ§ç¯ç³»ã¯ã¡ã¢ã£ã¦ãããªãã¨å¾ã§ã¯ã¾ãã®ã§ãèªåãå¿ è¦ãªç¯å²ã§æé ãæ®ãã¾ãã
- åºæ¬ç㪠WSL 2 ç°å¢æ§ç¯
- å¿«é©ã«å©ç¨ããããã®è¨å®
- éçºã«å¿ è¦ãªããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«
Azure éçºã«å¿ è¦ãªããã±ã¼ã¸ã¨ C# / Node.js 㯠WSL 2 ã«ç´æ¥ã¤ã³ã¹ãã¼ã«ãã¾ãããPython ã Go ãªã©ã¯åºæ¬çã« VS Code ã® Dev Container çµç±ã§ä½¿ãã¨ããå²ãåã£ãæ§æã«ãã¦ãã¾ãã
ã¡ãªã¿ã«ã¡ã¤ã³ãã·ã³ã¯ Windows 㨠Visual Studio å°ç¨ã«ãã¦ããã®ã§ããã®éè³¼å ¥ãã Tiger Lake NUC ä¸ã« WSL 2 㨠Visual Studio Code ã®ç°å¢ãæ§ç¯ãã¦ãå¿ è¦ãªæã«ãªã¢ã¼ããã¹ã¯ãããã§ä½¿ã£ã¦ãã¾ãã
èªå® ã® NUC ã¯æç·ã§ç¹ãã§å¸¸æ稼åããã¦ããã®ã§ããããã£ãç¨éã«ã¯é©ãã¦ãã¾ãã
åºæ¬ç㪠WSL 2 ç°å¢æ§ç¯
Visual Studio Code 㨠Remote æ¡å¼µãã¤ã³ã¹ãã¼ã«
ã»ã¨ãã©ã®äººã Visual Studio Code ãã¤ã³ã¹ãã¼ã«ãã¦ããã¨æãã®ã§ããã®ã»ã¯ã·ã§ã³ã¯ã»ã¼ä¸è¦ãªæããããã¾ãããåæã« Remote æ¡å¼µã¯å¿ è¦ãªã®ã§ä¸å¿æ¸ãã¦ããã¾ãã
Remote Development Extension Pack ãã¤ã³ã¹ãã¼ã«ããã°ãSSH / WSL 2 / Container åãã®ãªã¢ã¼ãéçºãå¯è½ã«ãªãã¾ãããããç¡ãã¨å§ã¾ãã¾ããã
WSL 2 ã®ã¤ã³ã¹ãã¼ã«ã¨è¨å®
æè¿ã¯ Docs ã«ãã£ããã¨ããããã¥ã¡ã³ããæã£ã¦ããã®ã§ãWSL 2 ã®ã¤ã³ã¹ãã¼ã«ã¯æ¸ãã¦ããæé éãã«åèµ·åãã¤ã¤è¡ãã°åé¡ãªãã§ããåèµ·åã¨æ¸ãã¦ããã¿ã¤ãã³ã°ã§è¡ã£ã¦ãããªãã¨ã¯ã¾ãã¾ããInsider Preview ã ã¨ç°¡åãããã§ãããä»ã®ã¨ããã¯åå¥ã«è¨å®ãå¿ è¦ã§ãã
WSL 2 ã®ããã©ã«ãè¨å®ã®ã¾ã¾ã ã¨è¥å¹²ä½¿ãã«ããé¨åãããã®ã§ãè¨å®ã Windows 㨠WSL 2 ã®ããããã§è¿½å ãã¦æ¹åãã¾ããè¨å®ã®ãªãã¡ã¬ã³ã¹ã¯ Docs ã«ããã¾ãã
Insider Preview ã§ã¯æ¹åããã¦ãããããã§ãããããã©ã«ãã 㨠WSL 2 ã® VM ãã¡ã¢ãªãé£ãã¤ããã¦ãã¾ã£ãã®ã§ã%USERPROFILE%\.wslconfig
ãä½æã㦠WSL 2 ã¸ã®ã¡ã¢ãªå²ãå½ã¦ä¸éã追å ãã¾ããã
[wsl2] memory=16GB
NUC 㯠32GB ã®ã¡ã¢ãªãç©ãã§ããã®ã§ååãå²ãå½ã¦ãããã«ãã¾ããã
ããä¸ã¤ã¯ WSL 2 å´ã« Windows ã® PATH
ãèªåçã«è¿½å ããã¦ãã¾ã件ã§ããããã㯠WSL 2 å´ã§ /etc/wsl.conf
ãä½æãã¦ã追å ããªãããã«å¤æ´ãã¾ããã
[interop] appendWindowsPath=false
çµæ§ãã®æåã§æ··ä¹±ãããã¨ãå¤ãã£ãã®ã§ãWSL 2 㨠Windows ã¯åãé¢ãã¦ããã¾ãã
ãã®ã¾ã¾ã 㨠VS Code ã® Remote éçºã«å½±é¿ãåºãã®ã§ code
ã«å¯¾ã㦠alias ã追å ãã¦å¯¾å¿ãã¾ããã
alias code="/mnt/c/Users/shibayan/AppData/Local/Programs/Microsoft\ VS\ Code/bin/code"
ãã㧠code .
ã¨ã¿ã¼ããã«ã§æã¦ã°ãããã¾ã§éã Windows å´ã§ WSL 2 ã®ãã£ã¬ã¯ããªãéãã¾ãã
Docker Desktop ãã¤ã³ã¹ãã¼ã«
VS Code 㧠Dev Container ã使ãããã«å¿ è¦ãªã®ã§ Docker Desktop ãã¤ã³ã¹ãã¼ã«ãã¾ããã¤ã³ã¹ãã¼ã«æã« WSL 2 ãæå¹åããã¦ããã¨ãè¯ãæãã« WSL 2 Backend ãæå¹åãã¦ããã¾ããã
è¨å®ç»é¢ã§ WSL 2 Based Engine ãæå¹åããã¦ãããã¨ã確èªãã¦ããã° OK ã§ãã
ã¤ã³ã¹ãã¼ã«å¾ã« WSL 2 å´ãã docker
ã³ãã³ããå©ããããã«ãªã£ã¦ãããã¨ã確èªãã¦ããã¾ããã¨ã©ã¼ã«ãªã£ãå ´å㯠WSL 2 㨠Docker Engine ã®åèµ·åã§å¤§ä½è§£æ±ºãã¾ããã
å¿«é©ã«å©ç¨ããããã®è¨å®
Windows Terminal ã®éå§ãã£ã¬ã¯ããªãå¤æ´
WSL 2 ãã¤ã³ã¹ãã¼ã«ããã¦ãã㨠Windows Terminal ã¯èªåçã«ãããã¡ã¤ã«ã追å ãã¦ãããã®ã§ä¾¿å©ã§ãããããã©ã«ãã§ã¯éå§ãã£ã¬ã¯ããªã Windows å´ã® %USERPROFILE%
ã«ãªã£ã¦ããã®ã§ä¸ä¾¿ã§ãã
Windows å´ã®ãã¡ã¤ã«ã·ã¹ãã ã WSL 2 ããåç §ããã¨ããã©ã¼ãã³ã¹ãããªãæªãã®ã§ãåºæ¬ã¯ WSL 2 å´ã®ãã¡ã¤ã«ã·ã¹ãã ã«å¯ãã¦ãããæ¹ã便å©ã§ãã
æå㯠/home/shibayan
ã¨ã§ãæ¸ãã¦ããã°ãããã¨æã£ãã®ã§ãããWindows ä¸ã§ã®ãã¹ãæå®ããå¿
è¦ããããããã®ã§ã以ä¸ã®ããã«æå®ãã¾ããã
\\wsl$\Ubuntu-20.04\home\shibayan
ãã㧠Windows Terminal 㧠WSL 2 ãèµ·åããã°ã常ã«ãã¼ã ããéå§ã§ãã¾ãã
ããã©ã¼ãã³ã¹ãè¯ãã®ã§ Node.js ã使ã£ãéçºãæãã¾ããã½ã¼ã¹ã³ã¼ã㯠GitHub ã«å ¨ã¦ç½®ãã¦ããã®ã§ãWindows ã¨å ±æã¯ããã« WSL 2 å´ã§ clone ããããã«ãã¦ãã¾ãã
Git ã®èªè¨¼æ å ±ã Windows å´ã¨å ±æ
å®ã¯æå¤ã«ç¥ããã¦ããªãã£ã½ãã¦å°ãé©ããã®ã§ãããWindows å´ã§ Git Credential Manager ã使ã£ã¦ä¿åãããèªè¨¼æ å ±ã¯ãè¨å®ã追å ããã¨ç°¡åã« WSL 2 å´ãããå©ç¨ã§ãã¾ãã
Git Credential Manager Core ãå¿ è¦ãªã®ã§ãææ°ã® Git for Windows ãå ¥ãã¦ããã¾ãã
å ±æããããã®è¨å®ã¯å ¬å¼ããã¥ã¡ã³ãã«ããããã«ãWindows å´ã® Git Credential Manager Core ã WSL 2 å´ã® Git ã§ã使ãããã«ããã ãã§ãã
Git ã®ã¤ã³ã¹ãã¼ã«ãã£ã¬ã¯ããªãå¼ã£ã¦ããªãéãã³ããã§å®è¡ããã ãã§çµããã¾ãã
git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/libexec/git-core/git-credential-manager-core.exe"
ãã㧠WSL 2 ãã GitHub ã® MFA ãã¯ãªã¢ãã¤ã¤ãSSH ãã¼ã®ç®¡çç¡ãã§æ±ãã¾ããããªã便å©ã§ãã
éçºã«å¿ è¦ãªããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«
.NET Core / .NET SDK
C# ã使ã£ãéçºãã¡ã¤ã³ã§è¡ã£ã¦ããã®ã§ .NET Core / .NET SDK ã®ã¤ã³ã¹ãã¼ã«ãéè¦ã§ãããapt ã«ã¯ .NET 6 Preview ãå ¬éããã¦ããªãã®ã§ã¤ã³ã¹ãã¼ã«ã¹ã¯ãªããã使ãããã«ãã¦ãã¾ãã
å
¬å¼ãµã¤ããã dotnet-install.sh
ããã¦ã³ãã¼ããã¦é©å½ã«å®è¡æ¨©éãä»ããã°ã以ä¸ã®ããã«ãã©ã¡ã¼ã¿ã渡ãã¦ãµã¯ãã¨ã¤ã³ã¹ãã¼ã«ã§ãã¾ãã
# ææ°ã® LTS ãã¼ã¸ã§ã³ (.NET Core 3.1) ./dotnet-install.sh -c LTS # ææ°ã® Current ãã¼ã¸ã§ã³ (.NET 5.0) ./dotnet-install.sh -c Current # ææ°ã® .NET 6.0 Preview ãã¼ã¸ã§ã³ ./dotnet-install.sh -c 6.0 # æ示çã«ãã¼ã¸ã§ã³æå®å¯è½ ./dotnet-install.sh -v 6.0.100-preview.6.21355.2
$HOME/.dotnet
ã«ã¤ã³ã¹ãã¼ã«ãããã®ã§ããã®ãã£ã¬ã¯ããªã PATH
ã«è¿½å ããã°å®äºã§ãã
export PATH="$HOME/.dotnet:$PATH"
é©å½ã« dotnet --info
ãå®è¡ããã¨ãã¤ã³ã¹ãã¼ã«ããã¦ãã SDK ã確èªã§ãã¾ãã
Azure Functions v4 ã®ãã㪠.NET 6 Preview ãå¿ è¦ãªã¢ããªã±ã¼ã·ã§ã³ã®æ¤è¨¼ãããã§æãã¾ãã
Node.js (nvm)
C# ã®æ¬¡ã« Node.js ã使ããã¨ãå¤ãã®ã¨ãWindows ä¸ã 㨠npm install
ã®ããã©ã¼ãã³ã¹ãæªãã®ã§ WSL 2 ä¸ã§å©ç¨ãã¾ãããããå
¬å¼ããã¥ã¡ã³ãã« nvm ã使ã£ãã¤ã³ã¹ãã¼ã«æ¹æ³ãè¼ã£ã¦ããã®ã§ç°¡åã§ãã
åºæ¬çã« LTS ã使ãããã«ãã¦ããã®ã§ãnvm 㧠LTS ãã¼ã¸ã§ã³ã§ãã v14.x ãå ¥ãã¦ãã¾ãã
.NET SDK ã®æã®ããã« nvm install --lts
ã³ãã³ãä¸çºã§å
¥ãã®ã§ç°¡åã§ãããnvm ã¤ã³ã¹ãã¼ã«æã« PATH
ã¯èªåã§éãã¦ãããã®ã§ã.NET SDK ã®æããæéã¯çãã¾ããã
Azure CLI
Azure éçºããã¦ããã¨å¿ ãå¿ è¦ã«ãªã Azure CLI 㯠WSL 2 å´ã«ãå ¥ãã¦ããã¾ããèªåã¤ã³ã¹ãã¼ã«ç¨ã®ã¯ã³ã©ã¤ãã¼ãå ¬éããã¦ããã®ã§ããªãç°¡åã§ãã
æ®éã¯ã¤ã³ã¹ãã¼ã«å¾ã« Azure ã¸ã®ãã°ã¤ã³ãå¿ è¦ã§ãããWSL 2 ã®å ´å㯠Windows å´ã§ Azure CLI ã¸ã®ãã°ã¤ã³ãå®äºãã¦ããã°ãèªè¨¼æ å ±ã®å ±æãå¯è½ã§ãã
ä»åã¯ç¥ããªãéã« .aws
㨠.azure
ã¸ã®ã·ã³ããªãã¯ãªã³ã¯ãä½æããã¦ãã¾ããã
.azure
ã¸ã®ã·ã³ããªãã¯ãªã³ã¯ãåå¨ããªãå ´åã¯ãæ¹ãã¦æåã§ä½ãã°åé¡ãªãã§ãã
ãã㧠WSL 2 å´ã® Azure CLI ãã az login
ãå®è¡ãããã¨ãªãæä½å¯è½ã«ãªãã¾ããã
Azure Functions Core Tools
Azure Functions ã®éçºã«ã¯ Core Tools ãå¿ è¦ã«ãªãã®ã§ .NET SDK ã¨ã¯å¥ã«ã¤ã³ã¹ãã¼ã«ãã¾ããnpm ã§ãã¤ã³ã¹ãã¼ã«åºæ¥ã¾ãããnvm ã¨ã®ç¸æ§ãæªããããã®ã§ããã¥ã¡ã³ãã®éã apt ã使ã£ã¦å ¥ãã¾ãã
ç¾å¨ãå®è³ªçã«ãµãã¼ãããã¦ããã®ã¯ v3 ã®ã¿ãªã®ã§ãééãã¦å¤ã v2 ãå ¥ããªãããã«æ³¨æãã¾ãã
Azure CLI ã使ããããã«ãªã£ã¦ããã¨ãCore Tools ãã Functions ã®ãããã¤ãåºæ¥ãã®ã§éçºä¸ã«ã¯ä¾¿å©ã«ä½¿ãã¾ãããããã v4 ã®ãã¬ãã¥ã¼çãå
¬éãããããªæ°é
ãããã¾ãã*1
Terraform CLI
Terraform Provider for Azure ã¸ã¡ããã¡ãã PR ãæãã¦ããã®ã¨ããã£ãããªã½ã¼ã¹ãä½æãããå ´åã«ã¯ Terraform ã使ãããã«ãã¦ããã®ã§ CLI ã apt ã使ã£ã¦ã¤ã³ã¹ãã¼ã«ãã¾ãã
Windows ã®å ´å㯠zip ããã¦ã³ãã¼ããã¦ãæåã§ã©ãã PATH
ã®éã£ãå ´æã«ç½®ãå¿
è¦ãããã®ã§çµæ§æ©ãã®ã§ãããWSL 2 ã ã¨ãµã¯ãã¨æºåã§ãã¾ãã
èªåã§ãã«ããã Terraform Provider ã使ãã®ã WSL 2 ã®æ¹ã楽ã§ããã·ã³ã°ã«ãã¤ããªã§åä½ããã®ã§ Dev Container ã¾ã§ã¯æµç³ã«ä¸è¦ã¨ããæãã§ãã
Speedtest CLI
WSL 2 ã§ä»ã®ã¨ãã GUI ã使ãããè¦æ±ãç¡ãã®ã§ããã©ã¦ã¶ä¸è¦ã§ãããã¯ã¼ã¯é度ã測å®ã§ãã Speedtest CLI ãã¤ã³ã¹ãã¼ã«ãã¦ãã¾ãããããå ¬å¼ãµã¤ããè¦ãã°ç°¡åã«ã¤ã³ã¹ãã¼ã«åºæ¥ã¾ãã
ãããã¯ã¼ã¯é度ã測å®ãããçç±ã¨ãã¦ã¯ãWSL 2 ã§ã¯ä¸é¨ã®ç°å¢ã§ãããã¯ã¼ã¯é度ãç°å¸¸ã«é ããªããã¨ãããã¨ç¥ã£ãã®ã§ãããã®ç¢ºèªç®çã¨ããæãã§ãã
èªåã®ç°å¢ã§ã¯ç¹ã«ãããã¯ã¼ã¯å¨ãã®åé¡ã¯çºçãã¦ããªãã®ã§ãapt ã使ã£ãã¤ã³ã¹ãã¼ã«ã Docker Image ã® pull / push å«ãã¦å¿«é©ã«ä½¿ãã¦ãã¾ãã
ç®çãã¢ã¬ãªã®ã§ 1,2 å使ãã°ä¸è¦ã«ãªãããã§ãããã³ãã³ãã§ãµã¯ãã¨æ¸¬å®åºæ¥ãã®ã¯å°å³ã«ä¾¿å©ãªã®ã§å ¥ããã¾ã¾ã«ãã¦ãã¾ãã
*1:v4 㯠npm ã§ã¯ãã§ã«ãã¬ãã¥ã¼çãå ¬éæ¸ã¿