Install Azure CLI 2.0


Azure CLI 2.0 インストールしてみました。


自分がインストールしたのは、Mac なので、以下のコマンドを叩くだけ

curl -L | bash



$ ./az

    /  \    _____   _ _ __ ___
   / /\ \  |_  / | | | \'__/ _ \
  / ____ \  / /| |_| | | |  __/
 /_/    \_\/___|\__,_|_|  \___|

Welcome to the cool new Azure CLI!

Here are the base commands:

    account   : Manage subscriptions.
    acs       : Manage Azure Container Services.
    ad        : Synchronize on-premises directories and manage Azure Active Directory resources.
    appservice: Manage your Azure Web apps and App Service plans.
    batch     : Manage Azure Batch.
    cloud     : Manage the registered Azure clouds.
    component : Manage and update Azure CLI 2.0 (Preview) components.
    configure : Configure Azure CLI 2.0 Preview or view your configuration. The command is
                interactive, so just type `az configure` and respond to the prompts.
    container : Set up automated builds and deployments for multi-container Docker applications.
    disk      : Manage Azure Managed Disks.
    documentdb: Manage your Azure DocumentDB (NoSQL) database accounts.
    feature   : Manage resource provider features, such as previews.
    feedback  : Loving or hating the CLI?  Let us know!
    group     : Manage resource groups.
    image     : Manage custom Virtual Machine Images.
    iot       : Connect, monitor, and control millions of IoT assets.
    keyvault  : Safeguard and maintain control of keys, secrets, and certificates.
    lock      : Manage Azure locks.
    login     : Log in to access Azure subscriptions.
    logout    : Log out to remove access to Azure subscriptions.
    network   : Manages Azure Network resources.
    policy    : Manage resource policies.
    provider  : Manage resource providers.
    redis     : Access to a secure, dedicated cache for your Azure applications.
    resource  : Manage Azure resources.
    role      : Use role assignments to manage access to your Azure resources.
    snapshot  : Manage point-in-time copies of managed disks, native blobs, or other snapshots.
    sql       : Manage Azure SQL databases.
    storage   : Durable, highly available, and massively scalable cloud storage.
    tag       : Manage resource tags.
    vm        : Provision Linux or Windows virtual machines in seconds.
    vmss      : Create highly available, auto-scalable Linux or Windows virtual machines.


せっかくなので、CLI 2.0 を使って Azure Web Apps on Linux に Docker Hub からデプロイしてみたいと思います。
GUI で操作した時の記事はこちらです。



$ az login


To sign in, use a web browser to open the page and enter the code [認証用のコード] to authenticate.


すると、通常の Azure サブスクリプションの認証画面になりますので、いつもの通り認証すると以下の画面に遷移します。


サンプルを丸コピーで、dockerHubContainerPath しか変えてません。


# Variables
dockerHubContainerPath="appcontainers/wordpress" #format: <username>/<container-or-image>:<tag>

# Create a Resource Group
az group create --name myResourceGroup --location $location

# Create an App Service Plan
az appservice plan create --name AppServiceLinuxDockerPlan --resource-group myResourceGroup --location $location --is-linux --sku S1

# Create a Web App
az appservice web create --name $appName --plan AppServiceLinuxDockerPlan --resource-group myResourceGroup

# Configure Web App with a Custom Docker Container from Docker Hub
az appservice web config container update --docker-custom-image-name $dockerHubContainerPath --name $appName --resource-group myResourceGroup

で、こいつを実行してややしばらく待つと、Wordpress のインストール画面が表示されます。


シェルの中に az を埋め込めるのいいかも〜