Microsoft Azure
Common Services
I'd recommend taking a look at Microsoft's
tour of Azure services
Azure Command-Line Interface (CLI)
The
Azure Command-Line Interface documentation
is pretty solid, definitely check it out. They keep a list of
Azure services the Azure CLI can manage,
a handy reference to be aware of. I'm going to follow along in the docs, and
write notes here. Goal number one, time to
get started with Azure CLI.
Basic Notes
Some of these are taken from learning to
work with the Azure CLI
The Azure CLI
Azure's CLI, az, is a great way to turn repetitive tasks into a one-liner from
your command line. Their documentation walks you through
installing the Azure CLI
very well, so follow along their and come back when you have az set up.
File Shares
Virtual Machines
Functions
Virtual Network
SQL Database
Provisioning Storage
You can provision storage using either
the az CLI
or the python SDK
Python SDK:
pip install \
azure-cli-core \
azure-mgmt-storage \
azure-mgmt-resource \
azure-storage-blob \
azure-identity
Azure Cost Management
Below you'll find notes from a time I needed to learn how to control spending and manage bills for a team project in Microsoft Azure. Both the Azure Advisor and Azure Cost Management services provide ways to reduce the amount of money that is spent, and prevent it from being spent in the first place.
Before the project gets started, it may be a good idea to learn to estimate costs with the Azure pricing calculator.
Subscriptions
Interestingly, you can't create a subscription from the command line. You'll have to go to the Azure Portal and set one up manually. Once you have, however, continue along below:
Configurations
Check out
the documentation for az configure
Resource Groups
Create an Azure resource group
in LOCATION, (e.g. westus)
# Short form
az group create -n GROUP_NAME [-l LOCATION]
# Long form
az group create --name GROUP_NAME [--location LOCATION]
Set the default Azure resource group
to GROUP_NAME
az configure --defaults group=GROUP_NAME
Listing information about a resource group
resource_group='learn-ff1ca2e8-ec34-4b09-abf6-e1a70c9ce459'
resource_type='Microsoft.Web/sites'
az resource list \
--resource-group ${resource_group} \
--resource-type ${resource_type}
Providers
Print a list of resource providers
az provider list --output table
Register the resource provider for the Microsoft.Search namespace
# `--wait` until the registration has completed
az provider register --wait --namespace 'Microsoft.Search'
Show the registration status of a particular namespace
az provider show --namespace 'Microsoft.Search' --output table
Storage
Azure Storage for File Shares
Before you go crazy, be sure to check out the
pricing page
before following along below. If this is a new topic for you, check out the
intro page
for Azure Files as well.
Create a storage account
az storage account create \
--name ACCOUNT_NAME \
--resource-group GROUP_NAME \
--location 'westus' \
--kind StorageV2 \
--sku Standard_LRS
Create a file share
az storage share-rm create \
--resource-group GROUP_NAME \
--storage-account ACCOUNT_NAME \
--name SHARE_NAME
--access-tier TIER
Where TIER is one of cool, hot, or TransactionOptimized
After you've done these two steps, make sure you
secure the environment
before you continue on to
create a directory
and
upload a file.
You can
remove the storage account
and its contents whenever you'd like with the following command:
The next step is for me to
create an Azure website using the CLI
but one could just as easily
create a web app in the Azure portal
if that's less intimidating.
Azure App Service
If you need a web server to render content, use Azure's App Service. If, per chance, you find you don't actually need a web server, use their Static Web App service instead.
An App Service plan defines the resources that run an App Service app. Every App Service app must have a corresponding App Service plan in order to run it.
A single App Service plan can host multiple App Service apps.
Azure App Service
- Here is a useful walkthrough
- an HTTP-based service that enables you to build and host many types of web-based solutions without managing infrastructure. For example, you can host web apps, mobile back ends, and RESTful APIs in several supported programming languages.
List existing App Service plans
# Short form
az appservice plan list -o table
# Long form
az appservice plan list --output table
Create a new app service SERVICE_NAME
az appservice plan create \
--name SERVICE_NAME \
--resource-group GROUP \
--subscription SUBSCRIPTION \
--sku 'FREE'
Get the details of a source control deployment configuration
az webapp deployment source show \
--name WEB_APP_NAME \
--resource-group GROUP \
--subscription SUBSCRIPTION
Get the details for available web app deployment profiles
az webapp deployment list-publishing-profiles \
--name WEB_APP_NAME \
--resource-group GROUP \
--subscription SUBSCRIPTION
Set an environment variable
for an Azure web app
az webapp config appsettings set --settings KEY=VALUE
Delete an app service (and all apps within it)
az appservice plan delete --name SERVICE_NAME
Azure Web Apps
Create a web application APP_NAME
az webapp create \
--name APP_NAME \
--resource-group GROUP \
--plan SERVICE_NAME
Set the default web application to APP_NAME
az configure --defaults web=APP_NAME
Configure continuous deployment from GitHub repository REPO (https://github.com/ttrojan/helloworld)
az webapp deployment source config \
--name APP_NAME \
--resource-group GROUP \
--repo-url REPO \
--branch 'master' \
--git-token ${GITHUB_TOKEN}
Start a web app
resource_group='learn-ff1ca2e8-ec34-4b09-abf6-e1a70c9ce459'
name='sandboxappforlearning'
az webapp start \
--resource-group ${resource_group} \
--name=${name}
Stop a web app
resource_group='learn-ff1ca2e8-ec34-4b09-abf6-e1a70c9ce459'
name='sandboxappforlearning'
az webapp stop \
--resource-group ${resource_group} \
--name=${name}
List available runtimes
View the web app in your browser
az browse --name APPLICATION_NAME
Microsoft's documentation has a great article about the steps to
configure a Node.js app for Azure App Service
Cognitive Search
You won't be able to do much else using the command-line interface past this point. Follow along in the Azure documentation to learn how to create a search index