الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

الفصل 6الاسم في الدورة: Automate deployment of resources by using ARM templates or Bicep files

Deploy resources from ARM templates and Bicep

Clicking in the portal does not scale. Azure's own Infrastructure as Code is ARM templates (JSON) and Bicep (a short language that compiles to ARM). The exam asks you to read, change, deploy and export them. Terraform, the multi-cloud tool, follows in the Terraform summary.

  • 5 الدروس
  • 2 الأوامر

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

$ مستخدم عادي# بصلاحية root (أو مع sudo)

المهارات في هذا الفصل

  • أتمتة النشر بقوالب ARM و Bicep

6.1

Read an ARM template

An ARM template is JSON with fixed sections. Azure reads it and creates the resources in the right order.

storage.json
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "name": { "type": "string" },
    "sku":  { "type": "string", "defaultValue": "Standard_LRS", "allowedValues": ["Standard_LRS", "Standard_ZRS"] }
  },
  "resources": [{
    "type": "Microsoft.Storage/storageAccounts",
    "apiVersion": "2023-05-01",
    "name": "[parameters('name')]",
    "location": "[resourceGroup().location]",
    "sku": { "name": "[parameters('sku')]" },
    "kind": "StorageV2",
    "properties": { "minimumTlsVersion": "TLS1_2", "allowBlobPublicAccess": false }
  }],
  "outputs": { "id": { "type": "string", "value": "[resourceId('Microsoft.Storage/storageAccounts', parameters('name'))]" } }
}
SectionMeaning
parametersValues you give at deploy time
variablesValues computed inside the template
resourcesWhat to create
outputsValues returned after the deployment
[ … ]An expression: parameters(), resourceGroup(), concat(), resourceId()

الأوامر في هذا الدرس

6.2

Write the same in Bicep

Bicep is shorter, has types and autocomplete (VS Code extension), and compiles to the same ARM JSON.

storage.bicep
param name string
@allowed(['Standard_LRS', 'Standard_ZRS'])
param sku string = 'Standard_LRS'
 
resource st 'Microsoft.Storage/storageAccounts@2023-05-01' = {
  name: name
  location: resourceGroup().location
  sku: { name: sku }
  kind: 'StorageV2'
  properties: { minimumTlsVersion: 'TLS1_2', allowBlobPublicAccess: false }
}
 
output id string = st.id
az bicep install
az bicep build --file storage.bicep
az bicep decompile --file storage.json

الأوامر في هذا الدرس

6.3

Deploy a template

Deploy to a resource group (most common), a subscription, a management group or the tenant. Check first with what-if.

az deployment group what-if -g rg-data --template-file storage.bicep --parameters name=stshop2026
az deployment group create -g rg-data --template-file storage.bicep --parameters name=stshop2026 sku=Standard_ZRS
az deployment group create -g rg-data --template-file storage.json --parameters @storage.parameters.json
az deployment group list -g rg-data -o table
az deployment group show -g rg-data -n storage --query properties.outputs
ModeBehaviour
Incremental (default)Adds and changes resources; others in the group stay
CompleteDeletes resources in the group that are not in the template

انتبه

--mode Complete on the wrong resource group deletes everything else in it. Use what-if first.

الأوامر في هذا الدرس

6.4

Export a template from existing resources

Build once in the portal, then export the template and keep it in Git.

az group export --name rg-data > rg-data.json
  • In the portal: resource group → Export template, or Download a template for automation on any create page.
  • Exported templates often need clean-up (hard-coded names, unneeded properties).

الأوامر في هذا الدرس

6.5

Use parameter files

Keep one template and one parameter file per environment.

storage.parameters.json
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": { "name": { "value": "stshopprod" }, "sku": { "value": "Standard_ZRS" } }
}

Bicep can also use .bicepparam files: using 'storage.bicep' then param name = 'stshopprod'.

كل الأوامر في هذا الفصل