Skip to content

Latest commit

 

History

History
115 lines (70 loc) · 5.15 KB

az-hack.md

File metadata and controls

115 lines (70 loc) · 5.15 KB

az hack

az hack is a command-line utility for quickly bootstrapping Azure resources commonly used for a student hack project. With az hack create you will be able to spin up and configure databases, web hosting, and even artificial intelligence.

Provisioned resources

All resources are placed in the same resource group

Pricing Note: The database and Cognitive Services keys may incur charging. Please consult the documentation for up-to-date pricing information.

Configuration notes

All generated passwords, keys, and names will be displayed on the screen upon completion of the command. In addition, all values are stored as environmental variables in the website, and can be accessed in your application as such.

Note: To enable an easier-to-read output, use --output yaml

Note: You may want to consider using a package such as Node dotenv, python-dotenv, dotenv.net or PHP dotenv to simplify managing environmental variables for your application.

Installation

az hack is an Azure Command Line Interface (CLI) extension.

Cloud shell

  1. Navigate to https://shell.azure.com and authenticate
  2. Install the hack extension
az extension add --name hack

Azure cloud shell

Azure cloud shell allows you to access the Azure CLI without having to perform a local of the tooling. To access Azure cloud shell, navigate to the Azure portal, and select Cloud Shell in the upper right corner.

After launching Cloud Shell, install the hack extension by issuing the following command:

az extension add --name hack

NOTE: When launching Cloud Shell for the first time you will be prompted to create a storage account for its use. There may be a small charge incurred for this storage account.

Local installation

  1. Install Python
  2. Install Azure CLI
  3. Login
az login
  1. Install the hack extension
az extension add --name hack

Usage

create

az hack create --name
           --database {mysql, sql, cosmosdb}
           --runtime {python, tomcat, jetty, php, aspnet, node}
           --location
           [--ai]

Examples

Create a website running Python, a MySQL database, and enable artificial intelligence via Cognitive Services in West US.

az hack create --name sample --runtime python --database mysql --location westus --ai

Create a website running Node.js, and an instance of CosmosDB with Mongo API in UK South.

az hack create --name sample --runtime node --database cosmosdb

Parameters

name

Base name of the application. Must be 10 characters or less. A random set of characters will be placed at the end to ensure uniqueness.

database

Type of database to create - cosmosdb (for Mongo API), mysql, or sql

Note for MySQL If you are using Azure Databases for MySQL, you will need to enable SSL for your application to connect

Note about firewalls By default, the firewall for SQL or MySQL will be configured to only allow resources on Azure to connect to your database. To enable your local system to connect, you will need to add your IP address to the MySQL firewall rules or SQL firewall rules. You can determine your systems public IP address by using a search engine and searching "What is my IP".

runtime

Runtime or framework for website - tomcat or jetty for Java, php, python, aspnet, node

location

Region for the application. See full list by using az location list

ai

(Optional) Creates a key for use with Cognitive Services