{Azure Files}クイックスタート: Azure ファイル共有を作成して使用する

 

https://learn.microsoft.com/ja-jp/azure/storage/files/storage-how-to-use-files-portal?tabs=azure-cli


https://www.cloudou.net/storage/blob002/

NFS プロトコルは、Premium ファイル共有 (FileStorage アカウントの種類のファイル共有) 
でのみ使用できます


-- 1. 前作業

az login --use-device-code
az account show

az version

az configure --list-defaults
az configure --defaults location=japaneast
az configure --list-defaults

az group create \
--name rg01 \
--location japaneast

az group list

 

-- 2. マウント用vm作成


az vm create \
--resource-group rg01 \
--name vm01 \
--image Win2019Datacenter \
--size Standard_B1s \
--admin-username azureuser \
--admin-password 'passwordpassword' \
--os-disk-delete-option Delete \
--nic-delete-option Delete \
--public-ip-sku Standard \
--enable-agent false \
--enable-auto-update false

 

az vm list \
--resource-group rg01


-- 3. ストレージアカウントの作成

az storage account create \
--resource-group rg01 \
--name st123 \
--access-tier Hot \
--kind StorageV2 \
--sku Standard_LRS

 


az storage account list \
--resource-group rg01

az storage account show \
--resource-group rg01 \
--name st123


-- 4. Azure ファイル共有を作成する


az storage share-rm create \
--resource-group rg01 \
--storage-account st123 \
--name share01 \
--quota 10 \
--enabled-protocols SMB \
--access-tier Hot


az storage share-rm list \
--resource-group rg01 \
--storage-account st123


az storage share-rm show \
--resource-group rg01 \
--storage-account st123 \
--name share01

 

-- 5. 動作確認
マウント用vmで実行

$connectTestResult = Test-NetConnection -ComputerName st123.file.core.windows.net -Port 445
if ($connectTestResult.TcpTestSucceeded) {
    cmd.exe /C "cmdkey /add:`"st123.file.core.windows.net`" /user:`"localhost\st123`" /pass:`"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`""
    New-PSDrive -Name Z -PSProvider FileSystem -Root "\\st123.file.core.windows.net\share01" -Persist
} else {
    Write-Error -Message "Unable to reach the Azure storage account via port 445. Check to make sure your organization or ISP is not blocking port 445, or use Azure P2S VPN, Azure S2S VPN, or Express Route to tunnel SMB traffic over a different port."
}

 


-- 6. クリーンアップ


az group list

az group delete \
--name rg01 \
--yes

az group delete \
--name NetworkWatcherRG \
--yes