initial commit

Signed-off-by: Tuan-Dat Tran <tuan-dat.tran@tudattr.dev>
This commit is contained in:
Tuan-Dat Tran
2025-01-24 23:48:14 +01:00
commit b88d2a6806
16 changed files with 2461 additions and 0 deletions

View File

@@ -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
}
}
]
}

View File

@@ -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
}
}
]
}

View 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"
}
}
]
}
```