UNPKG

8.47 kBMarkdownView Raw
1# Microsoft Azure Xplat-CLI for Windows, Mac and Linux
2
3[![NPM version](https://badge.fury.io/js/azure-cli.png)](http://badge.fury.io/js/azure-cli) [![Build Status](https://travis-ci.org/Azure/azure-xplat-cli.png?branch=master)](https://travis-ci.org/Azure/azure-xplat-cli)
4
5This project provides a cross-platform command line interface for developers and IT administrators to develop, deploy and manage Microsoft Azure applications.
6
7## Features
8
9* Accounts Management
10* Azure Service Management
11 * Storage
12 * Websites
13 * Virtual machines
14 * Network
15 * Mobile Services
16 * Service Bus
17 * SQL Database
18* Azure Resource Management
19 * Generic resource groups and deployments management
20 * Role based access control
21 * Cmdlets for individual resource providers, including compute, storage, network, redis cache, insights, etc.
22 * Datalake
23* Key Vault
24
25For comdlets detail, type "azure" to navigate through the help system. Also, use `azure config mode` to switch between service management and resource management.
26
27## Endpoints for Azure
28
29The CLI targets **"Public Azure Cloud"** by default. You can get more information about the endpoints supported in different environments from [here](./Documentation/Endpoints.md).
30
31## Non-Interactive Authentication
32If you need to create an automation account for non interactive or scripting scenarios then please take a look at the documentation over [here](https://github.com/Azure/azure-sdk-for-node/blob/autorest/Documentation/Authentication.md).
33
34
35## Installation
36
37### Install from npm
38
39You can install the azure-cli npm package directly.
40```bash
41npm install -g azure-cli
42```
43
44### Install on Ubuntu
45The Xplat-CLI requires Node.js. Installation varies slightly by Ubuntu version.
46
47**Ubuntu 14.04 Trusty Tahr**
48
49On Ubuntu 14, the Node.js package is called nodejs-legacy. The npm package is installed first to get the Node Package Manager used to install the CLI.
50
51```bash
52sudo apt-get install nodejs-legacy
53sudo apt-get install npm
54sudo npm install -g azure-cli
55```
56**Ubuntu 12.04 Precise Pangolin**
57
58On Ubuntu 12, the version of Node.js available in the default package manager is too old. You can use the Personal Package Archive feature to install the current binary distribution. First, install the curl package to easily retrieve the install script.
59
60```bash
61sudo apt-get install curl
62curl -sL https://deb.nodesource.com/setup | sudo bash -
63sudo apt-get install -y nodejs
64sudo npm install -g azure-cli
65```
66
67### Install on a Docker Host
68
69In a Docker host, run:
70```bash
71sudo docker run -it microsoft/azure-cli
72```
73
74### Pre-compiled installers
75
76* [Windows](http://aka.ms/webpi-azure-cli)
77* [Mac](http://aka.ms/mac-azure-cli)
78* [Linux](http://aka.ms/linux-azure-cli)
79
80
81### Configure auto-complete
82
83Auto-complete is supported for Mac and Linux.
84
85To enable it in zsh, run:
86
87```bash
88echo '. <(azure --completion)' >> .zshrc
89```
90
91To enable it in bash, run:
92
93```bash
94azure --completion >> ~/azure.completion.sh
95echo 'source ~/azure.completion.sh' >> ~/.bash_profile
96```
97
98## Get Started
99
100* First, get authenticated with Microsoft Azure. For details, read [this article](http://azure.microsoft.com/en-us/documentation/articles/xplat-cli/).
101 * Option 1: Login with your Microsoft account, such as live-id, or organizational account, or service principals.
102 * Option 2: Download and import a publish settings file which contains a management certificate.
103
104If you use both mechanisms on the same subscription, Azure Active Directory authentication will be used by default. If you want to go back to management certificate authentication, please use ``azure logout``, which will remove the Azure Active Directory information and bring management certificate authentication back in.
105
106#### Login directly from xplat-cli (Azure Active Directory authentication)
107
108```bash
109# This will output an url and a device code for you to use browser to login
110azure login
111
112# This will prompt for your password in the console
113azure login -u <your organizational ID email address>
114
115# This will login in using a service principal
116azure login -u "<service-principal-id>" -p "<key>" --service-principal --tenant "<tenant-id>"
117```
118
119#### Use publish settings file (Management certificate authentication)
120
121```bash
122# Download a file which contains the publish settings information of your subscription.
123# This will open a browser window and ask you to log in to get the file.
124azure account download
125
126# Import the file you just downloaded.
127# Notice that the file contains credential of your subscription so you don't want to make it public
128# (like check in to source control, etc.).
129azure account import <file location>
130
131# Use the commands to manage your services/applications
132azure site create --location "West US" mywebsite
133```
134
135### azure cli with China Cloud
136```bash
137# This will log you into the China Cloud environment.
138# You can use same set of commands to manage your service/applications
139azure login -u <your organizational ID email address> -e AzureChinaCloud
140```
141
142### azure cli on Ubuntu
143If you want to run xplat cli on Ubuntu, then you should install **nodejs-legacy** instead of **nodejs**. For more information please check the following links:
144- [why there is a problem with nodejs installation on ubuntu](http://stackoverflow.com/questions/14914715/express-js-no-such-file-or-directory/14914716#14914716)
145- [how to solve the nodejs installation problem on ubuntu](https://github.com/expressjs/keygrip/issues/7)
146
147Please perform the installation steps in following order:
148```bash
149sudo apt-get install nodejs-legacy
150sudo apt-get install npm
151sudo npm install -g azure-cli
152```
153
154## 2 Modes
155
156Starting from 0.8.0, we are adding a separate mode for Resource Manager. You can use the following command to switch between the
157
158* Service management: commands using the Azure service management API
159* Resource manager: commands using the Azure Resource Manager API
160
161They are not designed to work together.
162
163```bash
164azure config mode asm # service management
165azure config mode arm # resource manager
166```
167
168**For more details on the commands, please see the [command line tool reference](http://go.microsoft.com/fwlink/?LinkId=252246&clcid=0x409) and this [How to Guide](http://azure.microsoft.com/en-us/documentation/articles/xplat-cli/)**
169
170## Docker
171
172Usage is the same as `vm create` command:
173
174 azure vm docker create [options] <dns-name> <image> <user-name> [password]
175
176This command only supports Ubuntu 14.04+ and CoreOS based images. Docker is configured on the VM using HTTPS as described here: https://docs.docker.com/articles/https/ By default, generated TLS certificates are placed in the `~/.docker` directory, and Docker is configured to run on port 2376. These can be configured using new options:
177
178 -dp, --docker-port [port] Port to use for docker [2376]
179 -dc, --docker-cert-dir [dir] Directory containing docker certs [~/.docker/]
180
181After the VM is created. It can be used as a Docker host with the `-H` option or `DOCKER_HOST` environment variable.
182
183 docker --tls -H tcp://<my-host>.cloudapp.net:2376 info
184
185Note: To run docker commands on windows make sure ssl agent is installed.
186
187## Error Diagnostic
188
189### use the -vv option to see the actual REST requests on the console.
190```bash
191azure site create --location "West US" mytestsite -vv
192```
193
194### Use web debugging proxy
195Say, use 'Fiddler', setup the following environment variables before execute commands.
196
197```bash
198set NODE_TLS_REJECT_UNAUTHORIZED=0
199set HTTPS_PROXY=http://127.0.0.1:8888
200```
201
202## Running Tests
203
204See [this page for instructions](https://github.com/Azure/azure-xplat-cli/wiki/Running-Tests) that describe how to run the test suite.
205
206## Learn More
207For documentation on how to host Node.js applications on Microsoft Azure, please see the [Microsoft Azure Node.js Developer Center](http://www.windowsazure.com/en-us/develop/nodejs/).
208
209## Contribute Code or Provide Feedback
210
211If you would like to become an active contributor to this project please follow the instructions provided in [Microsoft Azure Projects Contribution Guidelines](http://azure.github.io/guidelines/).
212
213Please send pull requests only to the **Dev branch**. Please make sure that you have checked in tests and recorded them live for your contribution. **Pull requests without sufficient tests will not be accepted.**
214
215If you encounter any bugs with the library please file an issue in the [Issues](https://github.com/Azure/azure-xplat-cli/issues) section of the project.