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.
- Azure App Service plan, which creates a VM in Azure for your site
- Azure App Service, which will host and run your site
- Database, including Azure SQL Database, Azure Database for MySQL, or CosmosDB using Mongo API
- Key for Azure Cognitive Services, which can be used to add artificial intelligence into your application
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.
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.
az hack
is an Azure Command Line Interface (CLI) extension.
- Navigate to https://shell.azure.com and authenticate
- Install the hack extension
az extension add --name hack
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.
az login
- Install the hack extension
az extension add --name hack
az hack create --name
--database {mysql, sql, cosmosdb}
--runtime {python, tomcat, jetty, php, aspnet, node}
--location
[--ai]
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
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.
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 or framework for website - tomcat or jetty for Java, php, python, aspnet, node
Region for the application. See full list by using az location list
(Optional) Creates a key for use with Cognitive Services