説明
GUI (Azure ポータル画面) を使用しての 仮想マシン作成は Microsoft Azure 上に Linux 仮想マシンを作ってみた で試してみました。
Azure では、このポータル画面以外にもインターフェースとして次のものを提供しています。
- Visual Studio
- PowerShell
- CLI
そこで、Mac に Azure を操作できる CLI を入れてみようと思います。
次の場所で Azure CLI 2.0 が公開され、インストール方法が記載されているので試してみます。
前提
Azire CLI は、Mac(OSX) 以外にも、Linux、Windowns も対応していますが、ここでは Mac にインストールします。
手順
1. Azure CLI インストール
Azure CLI 2.0 では、curl でインストーラを取得して手動でインストールするコマンドが記載されていました。
Mac では Homebrew を使ってインストールもできるので、そちらでインストールしてみます。
1.1. Homebrew でのインストール
まずローカルのHomebrew リポジトリをアップデートし、検索してみます。
$ brew update
$ brew search azure-cli
==> Searching local taps...
azure-cli ✔ azure-cli@1
みつかったので、インストールを行います。
$ brew install azure-cli
インストールできたか確認してみます。
$ az --version
azure-cli (2.0.22)
インストールできました。
1.2. 手動でのインストール
Homebrew 使いたくない場合は、手動でインストールを行います。
curl -L https://aka.ms/InstallAzureCli | bash
2. 参考: az コマンド
Azure CLIでは az が基礎コマンドとなり、サブコマンドを付け加えて各種命令を実施します。
$ az <サブコマンド>
az コマンドのヘルプから、サブコマンドを抜き出してみました。
$ az --help
コマンド | 説明 |
---|---|
account | Manage Azure subscription information. |
acr | Manage Azure Container Registries. |
acs | Manage Azure Container Services. |
ad | Synchronize on-premises directories and manage Azure Active Directory resources. |
advisor | (PREVIEW) Manage Azure Advisor. |
aks | Manage Kubernetes clusters. |
appservice | Manage App Service plans. |
backup | Commands to manage Azure Backups. |
batch | Manage Azure Batch. |
batchai | Batch AI. |
billing | Manage Azure Billing. |
cdn | Manage Azure Content Delivery Networks (CDNs). |
cloud | Manage registered Azure clouds. |
cognitiveservices | Manage Azure Cognitive Services accounts. |
consumption | Manage consumption of Azure resources. |
container | (PREVIEW) Manage Azure Container Instances. |
cosmosdb | Manage Azure Cosmos DB database accounts. |
disk | Manage Azure Managed Disks. |
dla | (PREVIEW) Manage Data Lake Analytics accounts, jobs, and catalogs. |
dls | (PREVIEW) Manage Data Lake Store accounts and filesystems. |
eventgrid | Manage Azure Event Grid topics and subscriptions. |
extension | Manage and update CLI extensions. |
feature | Manage resource provider features. |
functionapp | Manage function apps. |
group | Manage resource groups and template deployments. |
image | Manage custom virtual machine images. |
iot | (PREVIEW) Manage Internet of Things (IoT) assets. |
keyvault | Safeguard and maintain control of keys, secrets, and certificates. |
lab | Manage Azure DevTest Labs. |
lock | Manage Azure locks. |
managedapp | Manage template solutions provided and maintained by Independent Software Vendors (ISVs). |
monitor | Manage the Azure Monitor Service. |
mysql | Manage Azure Database for MySQL servers. |
network | Manage Azure Network resources. |
policy | Manage resource policies. |
postgres | Manage Azure Database for PostgreSQL servers. |
provider | Manage resource providers. |
redis | Access to a secure, dedicated Redis cache for your Azure applications. |
reservations | Manage Azure Reservations. |
resource | Manage Azure resources. |
role | Manage user roles for access control with Azure Active Directory and service principals. |
sf | Manage and administer Azure Service Fabric clusters. |
snapshot | Manage point-in-time copies of managed disks, native blobs, or other snapshots. |
sql | Manage Azure SQL Databases and Data Warehouses. |
storage | Manage Azure Cloud Storage resources. |
tag | Manage resource tags. |
vm | Provision Linux or Windows virtual machines. |
vmss | Manage groupings of virtual machines in an Azure Virtual Machine Scale Set (VMSS). |
webapp | Manage web apps. |
まとめ
Azure CLI のインストールは、簡単な操作であっという間にできました。
この Azure CLI のコマンドもヘルプからサブコマンドを抜き出してみましたが、サブコマンドに対してもさらにサブコマンドがあります。例えば、az vm コマンドの場合は次のように表示されました。
$ az vm --help
Group
az vm: Provision Linux or Windows virtual machines.
Subgroups:
availability-set : Group resources into availability sets.
boot-diagnostics : Troubleshoot the startup of an Azure Virtual Machine.
diagnostics : Configure the Azure Virtual Machine diagnostics extension.
disk : Manage the managed data disks attached to a VM.
encryption : Manage encryption of VM disks.
extension : Manage extensions on VMs.
image : Information on available virtual machine images.
nic : Manage network interfaces. See also `az network nic`.
run-command : (PREVIEW) Manage run commands on a Virtual Machine.
secret
unmanaged-disk : Manage the unmanaged data disks attached to a VM.
user : Manage user accounts for a VM.
Commands:
assign-identity : Enable managed service identity on a VM.
capture : Capture information for a stopped VM.
convert : Convert a VM with unmanaged disks to use managed disks.
create : Create an Azure Virtual Machine.
deallocate : Deallocate a VM.
:
:
:
:
様々な操作が CLI から実施できるので今後いろいろと試してみたいと思います。