Requirments: I need to create two following resources in azure which is 'azure storage account' and 'azure storage sync service' using ARM Templates.
Steps: I've two ARM template one is for creating 'azure storage account' another one is for creating 'azure storage sync service'.
- Need to create a 'azure storage account' from template number one it has to return 'azure storage account resource-id'
- Then need to create 'azure storage sync service' using that 'azure storage account resource-id'
i've tried with following arm templates but it does not work properly. anyone help me to get this ?
main template Storage sync service/deploy.json { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "storageSyncServicesname": { "type": "string", "defaultValue": "", "maxLength": 25 }, "Location": { "type": "string", "metadata": { "defaultValue": "" } }, "SyncGroupName": { "type": "string", "defaultValue":"ServerA-P01", "metadata": { "description": "The name of the storage endpoint." } }, "serverID": { "type": "string", "defaultValue":"", "metadata": { "description": "The name of the storage endpoint." } }, "enableServerEndpoint": { "type": "bool", "defaultValue": false }, "azureFileShareName": { "type": "string", "defaultValue": " ", "metadata": { "description": "The name of the file share." } }, "cloudendpoint": { "type": "string", "defaultValue": "bhendpoints", "metadata": { "description": "The name of the file share." } }, "storageAccountResourceId": { "type": "securestring", "defaultValue": "", "metadata": { "description": "The storage account access key." } }, "storageAccountTenantId": { "type": "string", "defaultValue": "", "metadata": { "description": "The storage server id." } }, "cloudTiering": { "type": "string", "metadata": { "description": "descrip" } }, "volumeFreeSpacePercent": { "type": "string", "metadata": { "description": "description" } }, "serverLocalPath": { "type": "string", "metadata": { "description": "description" } }, "Datepolicy": { "type": "string", "metadata": { "description": "description" } } "variables": { }, "resources": [
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2021-04-01",
"name": "linkedTemplate",
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[uri(deployment().properties.templatelink.uri, 'C:\\Users\\User\\Desktop\\poc\\storageaccount\\deploy.json')]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"deploymentFilePath": {
"value": "[parameters('deploymentFilePath')]"
}
}
}
},
{
"type": "Microsoft.StorageSync/storageSyncServices",
"apiVersion": "2022-06-01",
"name": "[parameters('storageSyncServicesname')]",
"location": "[parameters('Location')]",
"properties": {
"incomingTrafficPolicy": "AllowAllTraffic"
}
},
{
"type": "Microsoft.StorageSync/storageSyncServices/syncGroups",
"apiVersion": "2022-06-01",
"name": "[concat(parameters('storageSyncServicesname'), '/', if(not(empty(parameters('SyncGroupName'))), parameters('SyncGroupName'), 'defaultValue'))]",
"dependsOn": [
"[resourceId('Microsoft.StorageSync/storageSyncServices', parameters('storageSyncServicesname'))]
],
"properties": {}
},
{
"condition": "[parameters('enableServerEndpoint')]",
"type": "Microsoft.StorageSync/storageSyncServices/syncGroups/cloudEndpoints",
"apiVersion": "2022-06-01",
"name": "[concat(parameters('storageSyncServicesname'), '/', parameters('SyncGroupName'), '/', parameters('cloudendpoint'))]",
"dependsOn": [
"[resourceId('Microsoft.StorageSync/storageSyncServices', parameters('storageSyncServicesname'))]",
"[resourceId('Microsoft.StorageSync/storageSyncServices/syncGroups', parameters('storageSyncServicesname'), parameters('SyncGroupName'))]"
],
"properties": {
"storageAccountResourceId": "[reference('linkedTemplate').outputs.storageAccountResourceId.value]",
"azureFileShareName": "[parameters('azureFileShareName')]",
"storageAccountTenantId": "[parameters('storageAccountTenantId')]",
"friendlyName": "[parameters('azureFileShareName')]"
}
},
{
"condition": "[parameters('enableServerEndpoint')]",
"type": "Microsoft.StorageSync/storageSyncServices/syncGroups/serverEndpoints",
"apiVersion": "2019-02-01",
"name": "[concat(parameters('storageSyncServicesname'), '/', parameters('SyncGroupName'), '/', parameters('azureFileShareName'))]",
"dependsOn": [
"[resourceId('Microsoft.StorageSync/storageSyncServices', parameters('storageSyncServicesname'))]",
"[resourceId('Microsoft.StorageSync/storageSyncServices/syncGroups/cloudEndpoints', parameters('storageSyncServicesname'), parameters('SyncGroupName'), parameters('cloudendpoint'))]"
],
"properties": {
"serverLocalPath": "[parameters('serverLocalPath')]",
"cloudTiering": "[parameters('cloudTiering')]",
"volumeFreeSpacePercent": "[parameters('volumeFreeSpacePercent')]",
"tierFilesOlderThanDays": "[parameters('Datepolicy')]",
"storageAccountResourceId":"[reference('linkedTemplate').outputs.storageAccountResourceId.value]"
"serverResourceId": "[resourceId('Microsoft.StorageSync/storageSyncServices/registeredServers', parameters('storageSyncServicesname'), parameters('serverID'))]",
"offlineDataTransfer": "Off",
"initialDownloadPolicy": "NamespaceOnly",
"localCacheMode": "UpdateLocallyCachedFiles",
"initialUploadPolicy": "ServerAuthoritative"
}
}
]
}
Lincked template storageaccount\deploy.json
{ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "storageAccountName": { "defaultValue": "msftstoragepoc1998", "type": "String" },
"fileShareName": {
"defaultValue": "fileshere1",
"type": "String"
},
"location": {
"type": "string",
"defaultValue": "West US 2",
"metadata": {
"description": "The location where the resources will be created."
}
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2022-09-01",
"name": "[parameters('storageAccountName')]",
"location": "[parameters('location')]",
"sku": {
"name": "Standard_RAGRS",
"tier": "Standard"
},
"kind": "StorageV2",
"properties": {
"supportsHttpsTrafficOnly": true,
"encryption": {
"requireInfrastructureEncryption": false,
"services": {
"file": {
"keyType": "Account",
"enabled": true
},
"blob": {
"keyType": "Account",
"enabled": true
}
},
"keySource": "Microsoft.Storage"
},
"accessTier": "Hot",
"networkAcls": {
"bypass": "AzureServices",
"virtualNetworkRules": [],
"ipRules": [],
"defaultAction": "Allow"
},
"allowBlobPublicAccess": true,
"allowCrossTenantReplication": true,
"allowSharedKeyAccess": true,
"defaultToOAuthAuthentication": false,
"dnsEndpointType": "Standard",
"minimumTlsVersion": "TLS1_2",
"publicNetworkAccess": "Enabled"
}
},
{
"type": "Microsoft.Storage/storageAccounts/fileServices/shares",
"apiVersion": "2019-06-01",
"name": "[concat(parameters('storageAccountName'), '/default/', parameters('fileShareName'))]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]"
],
"properties": {
"accessTier": "TransactionOptimized",
"shareQuota": 5120,
"enabledProtocols": "SMB"
}
}
],
"outputs": {
"storageAccountResourceId": {
"type": "object",
"value": "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]",
"metadata": {
"description": "The Resource Id of the Storage Account."
}
}
}
}
when I run this using Powershell commend i got error like this
Line | 15 | New-AzResourceGroupDeployment ` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 09:22:23 - The deployment 'deploy' failed with error(s). Showing 1 out of 1 error(s). Status Message: Unable to process template | language expressions for resource | '/subscriptions/subscribtionid/resourceGroups/MSFT-assessment/providers/Microsoft.Resources/deployments/linkedTemplate' at line '172' and column '9'. 'The language expression property 'templatelink' doesn't exist, available properties are 'template, templateHash, parameters, mode, provisioningState'.' (Code:InvalidTemplate) CorrelationId: df65adfa-1459-4e81-83c8-7f89c3e81128
Requirments: I need to create two following resources in azure which is 'azure storage account' and 'azure storage sync service' using ARM Templates.
Steps: I've two ARM template one is for creating 'azure storage account' another one is for creating 'azure storage sync service'.
- Need to create a 'azure storage account' from template number one it has to return 'azure storage account resource-id'
- Then need to create 'azure storage sync service' using that 'azure storage account resource-id'