|
#! /usr/bin/env bash |
|
# requires cifs-utils - `apt install cifs-utils` |
|
|
|
group_name=joshgav-oryx-test-group |
|
group_location=westus2 |
|
|
|
storage_account_name=joshgavoryxsharetest |
|
storage_account_group_name=${group_name} |
|
storage_account_location=${group_location} |
|
share_name=intermediate |
|
local_mount_point=/mnt/azurefiles/ |
|
|
|
group_id=$(az group show --name ${group_name} --output tsv --query id) |
|
if [[ -z "${group_id}" ]]; then |
|
group_id=$(az group create --name ${group_name} --location ${group_location} \ |
|
--output tsv --query id) |
|
fi |
|
echo "ensured group [${group_id}]" |
|
|
|
storage_id=$(az storage account show \ |
|
--name ${storage_account_name} \ |
|
--resource-group ${storage_account_group_name} \ |
|
--output tsv --query id) |
|
if [[ -z "${storage_id}" ]]; then |
|
storage_id=$(az storage account create \ |
|
--name ${storage_account_name} \ |
|
--resource-group ${storage_account_group_name} \ |
|
--location ${storage_account_location} \ |
|
--output tsv --query id) |
|
fi |
|
echo "ensured storage account: [${storage_id}]" |
|
|
|
key=$(az storage account keys list \ |
|
--account-name ${storage_account_name} \ |
|
--resource-group ${storage_account_group_name} \ |
|
--query '[0].value' --output tsv) |
|
echo "got storage key: [${key}]" |
|
|
|
share_name=$(az storage share show \ |
|
--name ${share_name} \ |
|
--account-name ${storage_account_name} \ |
|
--account-key "${key}" \ |
|
--output tsv --query name) |
|
if [[ -z "${share_name}" ]]; then |
|
share_name=$(az storage share create \ |
|
--name ${share_name} \ |
|
--account-name ${storage_account_name} \ |
|
--account-key "${key}" \ |
|
--output tsv --query name) |
|
fi |
|
echo "ensured storage share: [${share_name}]" |
|
|
|
# `apt install cifs-utils` |
|
sudo mkdir -p ${local_mount_point} |
|
# for linux |
|
sudo mount -t cifs \ |
|
"//${storage_account_name}.file.core.windows.net/${share_name}" \ |
|
${local_mount_point} \ |
|
-o "vers=3.0,username=${storage_account_name},password=${key},dir_mode=0777,file_mode=0777,serverino" |