The links provided on this website are for informational purposes only. I do not necessarily agree with, endorse, or take responsibility for the content, views, or accuracy of any external websites linked here. Use them at your own discretion.
Azure Bicep and Azure Resource Manager (ARM) templates are both tools for defining and deploying Azure resources. Bicep is generally considered easier to use and more maintainable than ARM templates.
install VS code to create ARM or BICEP templates
https://code.visualstudio.com/download
Bicep documents
https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/
Azure Resource Manager documents
https://learn.microsoft.com/en-us/azure/azure-resource-manager/
Install Azure CLI
https://learn.microsoft.com/en-us/cli/azure/install-azure-cli
Upgrade existing Azure CLI to the latest version
az upgrade
Login to your Azure using browser based authentication
az login
login with service principal
az login --service-principal --username APP_ID --password CLIENT_SECRET --tenant TENANT_ID
Log out of your Azure subscription instance
az logout
Lists all the container registries under the current subscription.
az acr list
Log in to an Azure Container Registry through the Azure CLI or docker
az acr login --name REGISTRY_NAME
docker login myregistry.azurecr.io
Log in to an Azure Container Registry through the Docker CLI using service principal
az acr login --name REGISTRY_NAME --service-principal --username APP_ID --password CLIENT_SECRET --tenant TENANT_ID
Pull an image from Azure Container Registry
docker pull myregistry.azurecr.io/samples/nginx
Push an image from Azure Container Registry
docker push myregistry.azurecr.io/samples/nginx
Delete an image from Azure Container Registry
docker rmi myregistry.azurecr.io/samples/nginx
Create an azure container app
az containerapp create --name CONTAINER_NAME --resource-group RESOURCE_GROUP --image IMAGE --target-port PORT --ingress external --registry-server MYREGISTRY.azurecr.io --registry-identify REGISTRY_IRENTITY --user-assigned ID --environment ENVIRONMENT --min-replicas NUM --scale-rule-name my-http-scale --scale-rule-http-concurrency 20
Update an azure container app with environment variables
az containerapp update --name CONTAINER_NAME --resource-group RESOURCE_GROUP --image IMAGE --set-env-vars VARIABLE1= "DATA1" VARIABLE2="DATA2"
Upload SSL cert for an azure container app
az containerapp ssl upload --certificate-file CERT_FILE --environment CONTAINER_APP_ENV --hostname HOST_URL --certificate-name CERT_NAME --name ACA_NAME --password SSL_CERT_PASSWORD --resource-group RESOURCE_GROUP_NAME
More CLI commands can be found here
https://learn.microsoft.com/en-us/cli/azure/reference-docs-index
param location string = 'East US'
param environmentName string = 'myContainerAppEnv'
param containerAppName string = 'myContainerApp'
param resourceGroupName string = 'myResourceGroup'
param logAnalyticsWorkspaceName string = 'myLogAnalyticsWorkspace'
param containerImage string = 'mcr.microsoft.com/azuredocs/containerapps-helloworld:latest'
param containerCpu float = 0.5
param containerMemory string = '1Gi'
param ingressExternal bool = true
param ingressTargetPort int = 80
resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2021-06-01' = {
name: logAnalyticsWorkspaceName
location: location
properties: {}
}
resource containerEnv 'Microsoft.App/managedEnvironments@2022-03-01' = {
name: environmentName
location: location
properties: {
appLogsConfiguration: {
destination: 'log-analytics'
logAnalyticsConfiguration: {
customerId: logAnalytics.properties.customerId
sharedKey: logAnalytics.properties.sharedKeys.primarySharedKey
}
}
}
}
resource containerApp 'Microsoft.App/containerApps@2022-03-01' = {
name: containerAppName
location: location
properties: {
managedEnvironmentId: containerEnv.id
configuration: {
ingress: ingressExternal ? {
external: true
targetPort: ingressTargetPort
} : null
}
template: {
containers: [
{
name: 'myapp'
image: containerImage
resources: {
cpu: containerCpu
memory: containerMemory
}
}
]
}
}
}
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string",
"defaultValue": "East US"
},
"environmentName": {
"type": "string",
"defaultValue": "myContainerAppEnv"
},
"containerAppName": {
"type": "string",
"defaultValue": "myContainerApp"
},
"logAnalyticsWorkspaceName": {
"type": "string",
"defaultValue": "myLogAnalyticsWorkspace"
},
"containerImage": {
"type": "string",
"defaultValue": "mcr.microsoft.com/azuredocs/containerapps-helloworld:latest"
},
"containerCpu": {
"type": "float",
"defaultValue": 0.5
},
"containerMemory": {
"type": "string",
"defaultValue": "1Gi"
},
"ingressExternal": {
"type": "bool",
"defaultValue": true
},
"ingressTargetPort": {
"type": "int",
"defaultValue": 80
}
},
"resources": [
{
"type": "Microsoft.OperationalInsights/workspaces",
"apiVersion": "2021-06-01",
"name": "[parameters('logAnalyticsWorkspaceName')]",
"location": "[parameters('location')]",
"properties": {}
},
{
"type": "Microsoft.App/managedEnvironments",
"apiVersion": "2022-03-01",
"name": "[parameters('environmentName')]",
"location": "[parameters('location')]",
"properties": {
"appLogsConfiguration": {
"destination": "log-analytics",
"logAnalyticsConfiguration": {
"customerId": "[reference(parameters('logAnalyticsWorkspaceName')).customerId]",
"sharedKey": "[listKeys(parameters('logAnalyticsWorkspaceName'), '2021-06-01').primarySharedKey]"
}
}
}
},
{
"type": "Microsoft.App/containerApps",
"apiVersion": "2022-03-01",
"name": "[parameters('containerAppName')]",
"location": "[parameters('location')]",
"properties": {
"managedEnvironmentId": "[resourceId('Microsoft.App/managedEnvironments', parameters('environmentName'))]",
"configuration": {
"ingress": "[if(parameters('ingressExternal'), json('{ \"external\": true, \"targetPort\": ' + parameters('ingressTargetPort') + ' }'), null)]"
},
"template": {
"containers": [
{
"name": "myapp",
"image": "[parameters('containerImage')]",
"resources": {
"cpu": "[parameters('containerCpu')]",
"memory": "[parameters('containerMemory')]"
}
}
]
}
}
}
]
}
We use cookies to analyze website traffic and optimize your website experience. By accepting our use of cookies, your data will be aggregated with all other user data.