1,创建Azure文件共享

# Change these four parameters as needed
ACI_PERS_RESOURCE_GROUP=ArcheryRG
ACI_PERS_STORAGE_ACCOUNT_NAME=archerysa 
# Storage account name must be between 3 and 24 characters in length and use numbers and lower-case letters only.
ACI_PERS_LOCATION=SoutheastAsia
ACI_PERS_SHARE_NAME=archeryfs

# Create the storage account with the parameters
az storage account create \
    --resource-group $ACI_PERS_RESOURCE_GROUP \
    --name $ACI_PERS_STORAGE_ACCOUNT_NAME \
    --location $ACI_PERS_LOCATION \
    --sku Standard_LRS

# Create the file share
az storage share create \
  --name $ACI_PERS_SHARE_NAME \
  --account-name $ACI_PERS_STORAGE_ACCOUNT_NAME

2,获得storage凭证

需要 storage account name , share name , storage access key 才能将Azure file share mount 到 Azure Continer instances。

# 1 storage account name
echo $ACI_PERS_STORAGE_ACCOUNT_NAME
# 2 share name 
echo $ACI_PERS_SHARE_NAME
# 3 storage account key 
STORAGE_KEY=$(az storage account keys list --resource-group $ACI_PERS_RESOURCE_GROUP --account-name $ACI_PERS_STORAGE_ACCOUNT_NAME --query "[0].value" --output tsv)
echo $STORAGE_KEY

3,部署容器并mount volume

# 创建incetion
az container create \
    --resource-group $ACI_PERS_RESOURCE_GROUP \
    --name inception \
    --image hhyo/inception \
    --ports 6669 \
    --command-line "/opt/inception/debug/mysql/bin/Inception --defaults-file=/archery/inception/inc.cnf"  \
    --vnet vNet-App-UAT-NonPCI \
    --subnet Subnet-App-UAT-NonPCI-Docker \
    --azure-file-volume-account-name $ACI_PERS_STORAGE_ACCOUNT_NAME \
    --azure-file-volume-account-key $STORAGE_KEY \
    --azure-file-volume-share-name $ACI_PERS_SHARE_NAME \
    --azure-file-volume-mount-path /archery/inception/

# 创建SQL
az container create \
    --resource-group $ACI_PERS_RESOURCE_GROUP \
    --name mysql \
    --image mysql:5.7 \
    --ports 3306 \
    --environment-variables 'MYSQL_DATABASE'='archery' 'MYSQL_ROOT_PASSWORD'='Ma100tP-ssrd' \
    --vnet vNet-App-UAT-NonPCI \
    --subnet Subnet-App-UAT-NonPCI-Docker \
    --azure-file-volume-account-name $ACI_PERS_STORAGE_ACCOUNT_NAME \
    --azure-file-volume-account-key $STORAGE_KEY \
    --azure-file-volume-share-name $ACI_PERS_SHARE_NAME \
    --azure-file-volume-mount-path /var/lib/mysql/

  • No labels