Azure CLI
Installation
Microsoft Learn Azure - Install Azure CLI on Windows
Globale Parameter
| Parameter | Beschreibung |
|---|---|
--output <type> / -o <type> | Werte: json, jsonc, none, table, tsv, yaml, yamlc. Standard: json |
--query <jmespath-query> | JMESPath Query String für JSON |
Get Started
Links
Befehle
Allgemein
az login
- Login für Zugriff auf Cloud-Umgebung
| Parameter | Beschreibung |
|---|---|
--tenant <tenant-id> | Angabe des Tenants |
az account
az account show
- aktuelle Benutzerinformationen anzeigen
az account list-locations
-
alle für die aktuelle Subscription unterstützten Regionen auflisten
-
Beispiel: alle zu verwendbaren Namen der Locations auflisten
az account list-locations --query [].name
az account list-locations --query "[].{displayName:displayName, name:name, geographyGroup:metadata.geographyGroup}"
az ad sp - Service Principal
- Verwaltung von Microsoft Entra Service Principals
Links
- Microsoft Learn Azure - Create an Azure service principal with Azure CLI
- Microsoft Learn Azure - az ad sp
az ad sp create-for-rbac
-
Service Principal für RBAC erstellen
-
Service Principal: Ersatz für Benutzernamen und Passwort
-
Scope kann zuerst per Befehl herausgefunden werden (
az acr- Container Registries )az acr show --resource-group <resource-group> --name <resource-name> --query id
az ad sp create-for-rbac --scopes <scope> --role 'Owner'
Beispiel:
az ad sp create-for-rbac --scopes "/subscriptions/.../resourceGroups/..." --role 'Owner'
Output:
{
"appId": "...",
"displayName": "...",
"password": "...",
"tenant": "..."
}
az provider
az provider register
-
Resource Provider wird für viele Dienste benötigt
-
Erstellen und Verwalten von Ressourcen eines bestimmten Typs
-
stellt sicher, dass Subscription erforderlichen APIs und Funktionen kennt und nutzen kann
-
Resource Provider für Web-Apps, App Services, Functions, … →
Microsoft.WebParameter Beschreibung --namespace <resouce-provider>Angabe des benötigten Resource Providers Beispiele:
az provider register --namespace Microsoft.Web
az provider register --namespace Microsoft.ContainerRegistry
Ressourcen
az group - Resource Groups
Microsoft Learn Azure - Manage Azure resource groups by using Azure CLI
Microsoft Learn Azure - az group
az group list
- alle Resource Groups anzeigen
az group show --name <name>
-
Resource Group anzeigen
Parameter Beschreibung --name <name>Name der Resource Group
az group create
-
Resource Group erstellen
Parameter Beschreibung --name <name>Name der Resource Group --location <location>/-l <location>Ort, Beispiele:
az group delete
- Resource Group löschen
az appservice - App-Service
Microsoft Learn Azure CLI - az appservice plan
App Service
- bieten Insights und Administrationserleichterungen
- Gefäss für Applikation
- in App Service können mehrere Apps laufen
- z. B. um Microservice-Architektur zu erreichen
az appservice plan create
- Erstellen eines App Services
| Parameter | Beschreibung |
|---|---|
--name <app-service-name> | Name des App Services |
--resource-group <resource-group-name> | Resource Group, in welchem der App Service erstellt werden soll |
--sku {B1, B2, B3, D1, F1, FREE, I1MV2, I1V2, I2MV2, I2V2, I3MV2, I3V2, I4MV2, I4V2, I5MV2, I5V2, I6V2, P0V3, P0V4, P1MV3, P1MV4, P1V2, P1V3, P1V4, P2MV3, P2MV4, P2V2, P2V3, P2V4, P3MV3, P3MV4, P3V2, P3V3, P3V4, P4MV3, P4MV4, P5MV3, P5MV4, S1, S2, S3, SHARED, WS1, WS2, WS3} | Preisstufe |
--is-linux | Hostet Web App auf einem Linux Worker |
az acr - Container Registries
Microsoft Learn Azure - az acr
- Verwaltung privater Registries mit Azure Container Registries
az acr show
-
Container Registry Details anzeigen
-
Beispiel (Scope herausfinden):
az acr show --name bbcssteilcr --resource-group bbcssteilContainerRegistryRG --query id
az container - Container
az container create
- Container-Ressource erstellen
| Parameter | Beschreibung |
|---|---|
--resource-group <resource-group-name> | Resource Group |
--name <name> | Name |
--image <image-name> | Container-Image |
--dns-name-label <dns-name> | DNS Name Label mit öffentlicher IP, muss in Azure Region einzigartig sein, <dns-name>.<location>.azurecontainer.io |
--ports <port1> <port2> ... <portN> | Liste von zu öffnenden Ports, Standard-Wert: [80] |
--os-type <os> | Betriebssystem-Typ, linux |
--memory <gb> | Memory in GB, auf 1 Dezimalstelle genau |
--cpu <cpu-cores> | Anzahl CPU Cores, auf 1 Dezimalstelle genau |
Beispiel:
az container create --resource-group myResourceGroup --name mycontainer --image mcr.microsoft.com/azuredocs/aci-helloworld --dns-name-label aci-demo --ports 80 --os-type linux --memory 1.5 --cpu 1
Output:
{
"comment": "...",
"ipAddress": {
"autoGeneratedDomainNameLabelScope": "Unsecure",
"dnsNameLabel": "<dns-name>",
"fqdn": "<dns-name>.<location>.azurecontainer.io",
"ip": "<ip>",
"ports": [
{
"port": 80,
"protocol": "TCP"
}
],
"type": "Public"
},
"comment": "..."
}
az storage account - Storage Account
az storage account create
- Storage Account erstellen
Beispiel:
az storage account create --name ssteilfirststorage --location "France Central" --resource-group bbcssteilResourceGroup --sku Standard_LRS --allow-blob-public-access false
az functionapp - Function App
az functionapp create
Beispiel:
az functionapp create --resource-group bbcssteilResourceGroup --consumption-plan-location westeurope --runtime node --runtime-version 20 --functions-version 4 --name bbcssteilLehrabschlussFunction --storage-account bbcssteilfirststorage
az mysql - MySQL
Microsoft Learn Azure - az mysql flexible-server
az mysql flexible-server create
-
MySQL Flexible Server erstellen
Parameter Beschreibung --name <name>Ressourcen-Name --resource-group <resource-group-name>Resource Group -
Beispiel:
az mysql flexible-server create --name ssteilMySqlFlexibleServer --resource-group databaseWithCliResourceGroup
az mysql flexible-server connect
-
zu MySQL Flexible Server verbinden
Parameter Beschreibung --name <name>/-n <name>Name der Datenbank-Ressource --interactiveöffnet MySQL-Shell --admin-user <username>/-u <username>Administrator-Benutzer --admin-password <password>/-p <password>Administrator-Passwort --database-name <db-name>/-d <db-name>Datenbank-Name az mysql flexible-server connect -n <servername> -u <username>
Password:
MySQL 8.0.41
mycli 1.27.2
Home: http://mycli.net
Bug tracker: https://github.com/dbcli/mycli/issues
Thanks to the contributor - Ishaan Bhimwal
<username>@<servername>.mysql.database.azure.com
(MySQL):(none)>
Deployment
az deployment - Deployment mit Bicep
- Microsoft Learn Azure - az deployment
- Microsoft Learn Q&A - az deployment group create : "The content for this response was already consumed"
az deployment group
-
Azure Resource Manager Vorlagen in Resource Group verwalten
-
create- startet Deployment mit
.bicep-Datei in Resource Group
Parameter Beschreibung --resource-group <resource-group-name>Resource Group - startet Deployment mit
az deployment sub
-
Azure Resource Manager Vorlagen in Subscription verwalten
-
create- startet Deployment mit
.bicep-Datei in Subscription
Parameter Beschreibung --resource-group <resource-group-name>Resource Group - startet Deployment mit
az bicep - BICEP
az bicep version
az bicep install
- installiert Bicep