initial commit
Signed-off-by: Tuan-Dat Tran <tuan-dat.tran@tudattr.dev>
This commit is contained in:
76
01_Beginner_JSON_templates/01_Create_first_deploy/README.md
Normal file
76
01_Beginner_JSON_templates/01_Create_first_deploy/README.md
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
# Create first template
|
||||||
|
|
||||||
|
Stuff taken from here:
|
||||||
|
<https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/template-tutorial-create-first-template?tabs=azure-cli>
|
||||||
|
|
||||||
|
## Login
|
||||||
|
|
||||||
|
```sh
|
||||||
|
azcli login --use-device-code
|
||||||
|
```
|
||||||
|
|
||||||
|
## Create alias (for Ubuntu)
|
||||||
|
|
||||||
|
```sh
|
||||||
|
echo 'alias az="azcli"'' > ~/.zshrc # or `~/.bashrc`
|
||||||
|
```
|
||||||
|
|
||||||
|
## Create a resource group for testing around
|
||||||
|
|
||||||
|
```sh
|
||||||
|
az group create --name tudattr_playground --location 'Germany West Central'
|
||||||
|
```
|
||||||
|
|
||||||
|
Result:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"id": "/subscriptions/1b7ef43e-9f52-41ad-a21f-52b38fc9c292/resourceGroups/tudattr_playground",
|
||||||
|
"location": "germanywestcentral",
|
||||||
|
"managedBy": null,
|
||||||
|
"name": "tudattr_playground",
|
||||||
|
"properties": {
|
||||||
|
"provisioningState": "Succeeded"
|
||||||
|
},
|
||||||
|
"tags": null,
|
||||||
|
"type": "Microsoft.Resources/resourceGroups"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Deploy something
|
||||||
|
|
||||||
|
```sh
|
||||||
|
az deployment group create --name blanktemplate --resource-group tudattr_playground --template-file ./azuredeploy.json
|
||||||
|
```
|
||||||
|
|
||||||
|
Result:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"id": "/subscriptions/1b7ef43e-9f52-41ad-a21f-52b38fc9c292/resourceGroups/tudattr_playground/providers/Microsoft.Resources/deployments/blanktemplate",
|
||||||
|
"location": null,
|
||||||
|
"name": "blanktemplate",
|
||||||
|
"properties": {
|
||||||
|
"correlationId": "8b7c845c-213b-4eb1-b342-23c08541db97",
|
||||||
|
"debugSetting": null,
|
||||||
|
"dependencies": [],
|
||||||
|
"duration": "PT1.2833636S",
|
||||||
|
"error": null,
|
||||||
|
"mode": "Incremental",
|
||||||
|
"onErrorDeployment": null,
|
||||||
|
"outputResources": [],
|
||||||
|
"outputs": null,
|
||||||
|
"parameters": null,
|
||||||
|
"parametersLink": null,
|
||||||
|
"providers": [],
|
||||||
|
"provisioningState": "Succeeded",
|
||||||
|
"templateHash": "11481920352792298114",
|
||||||
|
"templateLink": null,
|
||||||
|
"timestamp": "2025-01-24T19:43:15.571358+00:00",
|
||||||
|
"validatedResources": null
|
||||||
|
},
|
||||||
|
"resourceGroup": "tudattr_playground",
|
||||||
|
"tags": null,
|
||||||
|
"type": "Microsoft.Resources/deployments"
|
||||||
|
}
|
||||||
|
```
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
|
||||||
|
"contentVersion": "1.0.0.0",
|
||||||
|
"resources": []
|
||||||
|
}
|
||||||
100
01_Beginner_JSON_templates/02_Add_resource/README.md
Normal file
100
01_Beginner_JSON_templates/02_Add_resource/README.md
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
# Create resource
|
||||||
|
|
||||||
|
<https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/template-tutorial-add-resource?tabs=azure-cli>
|
||||||
|
|
||||||
|
## Resource properties
|
||||||
|
|
||||||
|
- name
|
||||||
|
- type
|
||||||
|
- apiVersion
|
||||||
|
|
||||||
|
## Re-Create Resource Group
|
||||||
|
|
||||||
|
```sh
|
||||||
|
az group create --name tudattr_playground --location 'Germany West Central'
|
||||||
|
```
|
||||||
|
|
||||||
|
Result:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"id": "/subscriptions/1b7ef43e-9f52-41ad-a21f-52b38fc9c292/resourceGroups/tudattr_playground",
|
||||||
|
"location": "germanywestcentral",
|
||||||
|
"managedBy": null,
|
||||||
|
"name": "tudattr_playground",
|
||||||
|
"properties": {
|
||||||
|
"provisioningState": "Succeeded"
|
||||||
|
},
|
||||||
|
"tags": null,
|
||||||
|
"type": "Microsoft.Resources/resourceGroups"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Create deployment
|
||||||
|
|
||||||
|
Storage account name must be between 3 and 24 characters in length and use numbers and lower-case letters only.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
az deployment group create --name addstorage --resource-group tudattr_playground --template-file ./create_storage_account.json
|
||||||
|
```
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"id": "/subscriptions/1b7ef43e-9f52-41ad-a21f-52b38fc9c292/resourceGroups/tudattr_playground/providers/Microsoft.Resourc
|
||||||
|
es/deployments/addstorage",
|
||||||
|
"location": null,
|
||||||
|
"name": "addstorage",
|
||||||
|
"properties": {
|
||||||
|
"correlationId": "b6581c8c-3958-4ec5-9128-26a21e05ac38",
|
||||||
|
"debugSetting": null,
|
||||||
|
"dependencies": [],
|
||||||
|
"duration": "PT2.155861S",
|
||||||
|
"error": null,
|
||||||
|
"mode": "Incremental",
|
||||||
|
"onErrorDeployment": null,
|
||||||
|
"outputResources": [
|
||||||
|
{
|
||||||
|
"id": "/subscriptions/1b7ef43e-9f52-41ad-a21f-52b38fc9c292/resourceGroups/tudattr_playground/providers/Microsoft.S
|
||||||
|
torage/storageAccounts/tudattrstorageaccount",
|
||||||
|
"resourceGroup": "tudattr_playground"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"outputs": null,
|
||||||
|
"parameters": null,
|
||||||
|
"parametersLink": null,
|
||||||
|
"providers": [
|
||||||
|
{
|
||||||
|
"id": null,
|
||||||
|
"namespace": "Microsoft.Storage",
|
||||||
|
"providerAuthorizationConsentState": null,
|
||||||
|
"registrationPolicy": null,
|
||||||
|
"registrationState": null,
|
||||||
|
"resourceTypes": [
|
||||||
|
{
|
||||||
|
"aliases": null,
|
||||||
|
"apiProfiles": null,
|
||||||
|
"apiVersions": null,
|
||||||
|
"capabilities": null,
|
||||||
|
"defaultApiVersion": null,
|
||||||
|
"locationMappings": null,
|
||||||
|
"locations": [
|
||||||
|
"germanywestcentral"
|
||||||
|
],
|
||||||
|
"properties": null,
|
||||||
|
"resourceType": "storageAccounts",
|
||||||
|
"zoneMappings": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"provisioningState": "Succeeded",
|
||||||
|
"templateHash": "13441018268045530495",
|
||||||
|
"templateLink": null,
|
||||||
|
"timestamp": "2025-01-24T22:31:48.986230+00:00",
|
||||||
|
"validatedResources": null
|
||||||
|
},
|
||||||
|
"resourceGroup": "tudattr_playground",
|
||||||
|
"tags": null,
|
||||||
|
"type": "Microsoft.Resources/deployments"
|
||||||
|
}
|
||||||
|
```
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
|
||||||
|
"contentVersion": "1.0.0.0",
|
||||||
|
"resources": [
|
||||||
|
{
|
||||||
|
"type": "Microsoft.Storage/storageAccounts",
|
||||||
|
"apiVersion": "2021-09-01",
|
||||||
|
"name": "tudattrstorageaccount",
|
||||||
|
"location": "germanywestcentral",
|
||||||
|
"sku": {
|
||||||
|
"name": "Standard_LRS"
|
||||||
|
},
|
||||||
|
"kind": "StorageV2",
|
||||||
|
"properties": {
|
||||||
|
"supportsHttpsTrafficOnly": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
|
||||||
|
"contentVersion": "1.0.0.0",
|
||||||
|
"parameters": {
|
||||||
|
"storageName": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 3,
|
||||||
|
"maxLength": 24
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"resources": [
|
||||||
|
{
|
||||||
|
"type": "Microsoft.Storage/storageAccounts",
|
||||||
|
"apiVersion": "2021-09-01",
|
||||||
|
"name": "[parameters('storageName')]",
|
||||||
|
"location": "germanywestcentral",
|
||||||
|
"sku": {
|
||||||
|
"name": "Standard_LRS"
|
||||||
|
},
|
||||||
|
"kind": "StorageV2",
|
||||||
|
"properties": {
|
||||||
|
"supportsHttpsTrafficOnly": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
|
||||||
|
"contentVersion": "1.0.0.0",
|
||||||
|
"parameters": {
|
||||||
|
"storageName": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 3,
|
||||||
|
"maxLength": 24
|
||||||
|
},
|
||||||
|
"storageSKU": {
|
||||||
|
"type": "string",
|
||||||
|
"defaultValue": "Standard_LRS",
|
||||||
|
"allowedValues": [
|
||||||
|
"Standard_LRS",
|
||||||
|
"Standard_GRS",
|
||||||
|
"Standard_RAGRS",
|
||||||
|
"Standard_ZRS",
|
||||||
|
"Premium_LRS",
|
||||||
|
"Premium_ZRS",
|
||||||
|
"Standard_GZRS",
|
||||||
|
"Standard_RAGZRS"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"resources": [
|
||||||
|
{
|
||||||
|
"type": "Microsoft.Storage/storageAccounts",
|
||||||
|
"apiVersion": "2021-09-01",
|
||||||
|
"name": "[parameters('storageName')]",
|
||||||
|
"location": "eastus",
|
||||||
|
"sku": {
|
||||||
|
"name": "[parameters('storageSKU')]"
|
||||||
|
},
|
||||||
|
"kind": "StorageV2",
|
||||||
|
"properties": {
|
||||||
|
"supportsHttpsTrafficOnly": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
120
01_Beginner_JSON_templates/03_Add_parameters/README.md
Normal file
120
01_Beginner_JSON_templates/03_Add_parameters/README.md
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
# Add Parameters
|
||||||
|
|
||||||
|
<https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/template-tutorial-add-parameters?tabs=azure-cli>
|
||||||
|
|
||||||
|
## Re-Create Resource Group
|
||||||
|
|
||||||
|
```sh
|
||||||
|
az group create --name tudattr_playground --location 'Germany West Central'
|
||||||
|
```
|
||||||
|
|
||||||
|
Result:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"id": "/subscriptions/1b7ef43e-9f52-41ad-a21f-52b38fc9c292/resourceGroups/tudattr_playground",
|
||||||
|
"location": "germanywestcentral",
|
||||||
|
"managedBy": null,
|
||||||
|
"name": "tudattr_playground",
|
||||||
|
"properties": {
|
||||||
|
"provisioningState": "Succeeded"
|
||||||
|
},
|
||||||
|
"tags": null,
|
||||||
|
"type": "Microsoft.Resources/resourceGroups"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Run deployment
|
||||||
|
|
||||||
|
```sh
|
||||||
|
az deployment group create --name addnameparameter --resource-group tudattr_playground --template-file ./01_parameterized_create_storage_account.json --parameters storageName=tudattrstorageaccount
|
||||||
|
```
|
||||||
|
|
||||||
|
Result:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"id": "/subscriptions/1b7ef43e-9f52-41ad-a21f-52b38fc9c292/resourceGroups/tudattr_playground/providers/Microsoft.Resources/deployments/addnameparameter",
|
||||||
|
"location": null,
|
||||||
|
"name": "addnameparameter",
|
||||||
|
"properties": {
|
||||||
|
"correlationId": "46ac3cb0-227e-4770-bb0c-875d48c484fb",
|
||||||
|
"debugSetting": null,
|
||||||
|
"dependencies": [],
|
||||||
|
"duration": "PT22.7084386S",
|
||||||
|
"error": null,
|
||||||
|
"mode": "Incremental",
|
||||||
|
"onErrorDeployment": null,
|
||||||
|
"outputResources": [
|
||||||
|
{
|
||||||
|
"id": "/subscriptions/1b7ef43e-9f52-41ad-a21f-52b38fc9c292/resourceGroups/tudattr_playground/providers/Microsoft.Storage/storageAccounts/tudattrstorageaccount",
|
||||||
|
"resourceGroup": "tudattr_playground"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"outputs": null,
|
||||||
|
"parameters": {
|
||||||
|
"storageName": {
|
||||||
|
"type": "String",
|
||||||
|
"value": "tudattrstorageaccount"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"parametersLink": null,
|
||||||
|
"providers": [
|
||||||
|
{
|
||||||
|
"id": null,
|
||||||
|
"namespace": "Microsoft.Storage",
|
||||||
|
"providerAuthorizationConsentState": null,
|
||||||
|
"registrationPolicy": null,
|
||||||
|
"registrationState": null,
|
||||||
|
"resourceTypes": [
|
||||||
|
{
|
||||||
|
"aliases": null,
|
||||||
|
"apiProfiles": null,
|
||||||
|
"apiVersions": null,
|
||||||
|
"capabilities": null,
|
||||||
|
"defaultApiVersion": null,
|
||||||
|
"locationMappings": null,
|
||||||
|
"locations": ["germanywestcentral"],
|
||||||
|
"properties": null,
|
||||||
|
"resourceType": "storageAccounts",
|
||||||
|
"zoneMappings": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"provisioningState": "Succeeded",
|
||||||
|
"templateHash": "8372196208235658100",
|
||||||
|
"templateLink": null,
|
||||||
|
"timestamp": "2025-01-24T22:40:40.588825+00:00",
|
||||||
|
"validatedResources": null
|
||||||
|
},
|
||||||
|
"resourceGroup": "tudattr_playground",
|
||||||
|
"tags": null,
|
||||||
|
"type": "Microsoft.Resources/deployments"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Prove of fail
|
||||||
|
|
||||||
|
```sh
|
||||||
|
az deployment group create --name testskuparameter --resource-group tudattr_playground --template-file ./02_limited_parameterized_create_storage_account.json --parameters storageSKU=basic storageName=tudattrstorageaccount
|
||||||
|
```
|
||||||
|
|
||||||
|
Result:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": "InvalidTemplate",
|
||||||
|
"message": "Deployment template validation failed: 'The provided value for the template parameter 'storageSKU' is not valid. The value 'basic' is not part of the allowed value(s): 'Standard_LRS,Standard_GRS,Standard_RAGRS,Standard_ZRS,Premium_LRS,Premium_ZRS,Standard_GZRS,Standard_RAGZRS'.'.",
|
||||||
|
"additionalInfo": [
|
||||||
|
{
|
||||||
|
"type": "TemplateViolation",
|
||||||
|
"info": {
|
||||||
|
"lineNumber": 13,
|
||||||
|
"linePosition": 24,
|
||||||
|
"path": "properties.template.parameters.storageSKU.allowedValues"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
0
01_Beginner_JSON_templates/06_Add_outputs/README.md
Normal file
0
01_Beginner_JSON_templates/06_Add_outputs/README.md
Normal file
0
01_Beginner_JSON_templates/09_Add_tags/README.md
Normal file
0
01_Beginner_JSON_templates/09_Add_tags/README.md
Normal file
2072
99_docs/list-locations.json
Normal file
2072
99_docs/list-locations.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user