Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This article is part five in a series of seven articles that help developers get started with Azure.
- Part 1: Azure for developers overview
- Part 2: Key Azure services for developers
- Part 3: Hosting applications on Azure
- Part 4: Connect your app to Azure services
- Part 5: How do I create and manage resources in Azure?
- Part 6: Key concepts for building Azure apps
- Part 7: How am I billed?
Azure offers various tools to create and manage the resources your application used by your application.
Different tools support various use cases, and most Azure developers use a combination of tools depending on the job. For example, you might:
Use a GUI tool like the Azure portal or the Azure Tools extension for VS Code when prototyping Azure resources for a new application. GUI tools guide you through the process of creating new services and let you review and select the options for a service using drop-down menus and other graphical elements.
Write a script using the Azure CLI or Azure PowerShell to automate a common task. For example, you might create a script that creates a basic dev environment for a new web application consisting of an Azure App Service, a database, and blob storage. Writing a script ensures consistent resource creation and is faster than using a UI.
Use Infrastructure as code (IaC) tools to declaratively deploy and manage Azure resources. Tools like Terraform, Ansible, and Bicep let you codify Azure resources in declarative syntax, ensuring consistent deployment across environments and preventing environmental drift.
Azure portal
The Azure portal is a web-based interface designed for managing Azure resources. The Azure portal features:
- An easy-to-use, web-based UI for creating and managing Azure resources
- Create configurable dashboards
- Access subscription settings and billing information
VS Code Azure Tools Extension Pack
Developers using Visual Studio Code manage Azure resources directly in VS Code with the Azure Tools Extension Pack for VS Code. The Azure Tools Extension Pack lets you:
- Create, manage, and deploy code to websites with Azure App Service
- Create, browse, and query Azure databases
- Create, debug, and deploy Azure Functions directly in VS Code
- Deploy containerized applications in VS Code
For the full list of features, see the extension's download page.
Command line tools
Command line tools offer efficiency, repeatability, and the ability to script recurring tasks. Azure provides two command line tools: Azure CLI and Azure PowerShell. Both tools are functionally equivalent, so select the one that fits your workflow.
Azure CLI
The Azure CLI is a cross-platform command line tool that runs on Windows, Linux, and macOS. The Azure CLI:
- Features a concise, efficient syntax for managing Azure resources
- Outputs results as JSON (by default). Results can also be formatted as YAML, an ASCII table, or tab-separated values with no keys
- Provides the ability to query and shape output by using JMESPath queries
Azure CLI commands integrate easily into popular scripting languages like Bash, letting you script common tasks.
LOCATION='eastus'
RESOURCE_GROUP_NAME='msdocs-expressjs-mongodb-tutorial'
WEB_APP_NAME='msdocs-expressjs-mongodb-123'
APP_SERVICE_PLAN_NAME='msdocs-expressjs-mongodb-plan-123'
RUNTIME='NODE|14-lts'
# Create a resource group
az group create \
--___location $LOCATION \
--name $RESOURCE_GROUP_NAME
# Create an app service plan
az appservice plan create \
--name $APP_SERVICE_PLAN_NAME \
--resource-group $RESOURCE_GROUP_NAME \
--sku B1 \
--is-linux
# Create the web app in the app service
az webapp create \
--name $WEB_APP_NAME \
--runtime $RUNTIME \
--plan $APP_SERVICE_PLAN_NAME \
--resource-group $RESOURCE_GROUP_NAME
Azure PowerShell
Azure PowerShell is a set of cmdlets for managing Azure resources directly from PowerShell. Azure PowerShell is installed as a PowerShell module and works with PowerShell 7.0.6 LTS and PowerShell 7.1.3 or higher on all platforms including Windows, macOS, and Linux. It's also compatible with Windows PowerShell 5.1.
Azure PowerShell integrates tightly with the PowerShell language. Commands use a verb-noun format, and data returns as PowerShell objects. If you're already familiar with PowerShell scripting, Azure PowerShell is a natural choice.
$___location = 'eastus'
$resourceGroupName = 'msdocs-blob-storage-demo-azps'
$storageAccountName = 'stblobstoragedemo999'
# Create a resource group
New-AzResourceGroup `
-Location $___location `
-Name $resourceGroupName
# Create the storage account
New-AzStorageAccount `
-Name $storageAccountName `
-ResourceGroupName $resourceGroupName `
-Location $___location `
-SkuName Standard_LRS
For more information on choosing between Azure CLI and Azure PowerShell, see the article Choose the right command-line tool.
Infrastructure as code tools
Infrastructure as code is the process of managing and provisioning resources through declarative configuration files. Infrastructure as code tools use a declarative end state specification to guarantee a set of resources are created and configured the same way each time. Most infrastructure as code tools also monitor resources to ensure they remain configured in the desired state.
Azure supports various infrastructure as code tools for automated, repeated, and reliable deployments.
Bicep
Bicep is a ___domain-specific language (DSL) that uses declarative syntax to deploy Azure resources. It provides concise syntax, reliable type safety, and support for code reuse.
param ___location string = resourceGroup().___location
param storageAccountName string = 'toylaunch${uniqueString(resourceGroup().id)}'
resource storageAccount 'Microsoft.Storage/storageAccounts@2021-06-01' = {
name: storageAccountName
___location: ___location
sku: {
name: 'Standard_LRS'
}
kind: 'StorageV2'
properties: {
accessTier: 'Hot'
}
}
Terraform
Hashicorp Terraform is an open-source tool for provisioning and managing cloud infrastructure. It codifies infrastructure in configuration files that describe the topology of cloud resources. The Terraform CLI provides a simple mechanism to deploy and version configuration files to Azure.
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "main" {
name = "${var.prefix}-resources"
___location = var.___location
}
resource "azurerm_app_service_plan" "main" {
name = "${var.prefix}-asp"
___location = azurerm_resource_group.main.___location
resource_group_name = azurerm_resource_group.main.name
kind = "Linux"
reserved = true
sku {
tier = "Standard"
size = "S1"
}
}
resource "azurerm_app_service" "main" {
name = "${var.prefix}-appservice"
___location = azurerm_resource_group.main.___location
resource_group_name = azurerm_resource_group.main.name
app_service_plan_id = azurerm_app_service_plan.main.id
site_config {
linux_fx_version = "NODE|10.14"
}
}
Ansible
Ansible is an open-source product that automates cloud provisioning, configuration management, and application deployments. Using Ansible, you can provision virtual machines, containers, networks, and complete cloud infrastructures. Ansible also lets you automate the deployment and configuration of resources in your environment.
- hosts: localhost
connection: local
vars:
resource_group: myResourceGroup
webapp_name: myfirstWebApp
plan_name: myAppServicePlan
___location: eastus
tasks:
- name: Create a resource group
azure_rm_resourcegroup:
name: "{{ resource_group }}"
___location: "{{ ___location }}"
- name: Create App Service on Linux with Java Runtime
azure_rm_webapp:
resource_group: "{{ resource_group }}"
name: "{{ webapp_name }}"
plan:
resource_group: "{{ resource_group }}"
name: "{{ plan_name }}"
is_linux: true
sku: S1
number_of_workers: 1
frameworks:
- name: "java"
version: "8"
settings:
java_container: tomcat
java_container_version: 8.5
Azure SDK and REST APIs
Azure resources can be created programmatically from code. This lets you write applications that dynamically provision Azure resources in response to user requests. The Azure SDK provides resource management packages in .NET, Go, Java, JavaScript, and Python that let you create and manage Azure resources directly in code. Alternatively, the Azure REST API lets you manage Azure resources through HTTP requests to a RESTful endpoint.