I am trying to deploy a documentDb from the Azure-Cli (version 0.10.2) and so I exported the template directly from azure portal.
This resulted in an error of:
InvalidRequestContent : The request content was invalid and could not be deserialized: 'Could not find member 'defaultValue' on object of type 'DeploymentParameterDefinition'. Path 'properties.parameters.arm_document_db.defaultValue'
Changing those to "value" results in:
InvalidDeploymentParameterType : The type of deployment parameter 'arm_document_db' should not be specified. Please see https://aka.ms/arm-deploy/#parameter-file for details.
checking this page indicates that type is required, but is all in lowercase. This gave the same error.
removing "type" then gives me this error:
InvalidRequestContent : The request content was invalid and could not be deserialized: 'Required property 'type' not found in JSON. Path 'properties.template.parameters.arm_document_db'
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"arm_document_db": {
"defaultValue": null,
"type": "SecureString"
},
"arm_document_db01": {
"defaultValue": "arm-document-db01",
"type": "String"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.DocumentDB/databaseAccounts",
"kind": "DocumentDB",
"name": "[parameters('arm_document_db01')]",
"apiVersion": "2015-04-08",
"location": "Japan West",
"tags": {},
"properties": {
"databaseAccountOfferType": "Standard",
"name": "[parameters('arm_document_db')]"
},
"dependsOn": []
}
]
}
The aka.ms link shows that 'type' is required, however the error says that it isn't. Many thanks in advance!
The error is not for azuredeploy.json. It's for azuredeploy.parameters.json.
Remove the "type" field from your parameters file.
Related
Hi Looking for a json file to create a tag with multiple value and apply one of the value when resource group gets created
Example
Tag name - Department|
Value1 - Technology|
Value2 - Finance|
Value3 - Manufacturing|
Value4 - Sales and Marketing|
I want to create a resource with name "Test-RG" and pass one of four TAG values to RG
Say "Technology"
ANy help is much appreciated
If I understood correctly your need, following the official documentation, you can parametrize the tags :
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"rgName": {
"type": "string",
"metadata": {
"description": "Name of the resourceGroup to create"
}
},
"rgLocation": {
"type": "string",
"defaultValue": "[deployment().location]",
"metadata": {
"description": "Location for the resourceGroup"
}
},
"resourceTags": {
"type": "object"
}
},
"resources": [
{
"type": "Microsoft.Resources/resourceGroups",
"apiVersion": "2020-06-01",
"name": "[parameters('rgName')]",
"location": "[parameters('rgLocation')]",
"tags": "[parameters('resourceTags')]",
"properties": {}
}
]
}
Then all you need is to pass a JSON object for resourceTags parameter when deploying the ARM template. You can either do it inline or using parameter files.
I am extending one of the Azure quick start template to deploy Azure Web App with VNET integration. The RG, network components and App Service plan are already created (using powershell). I am using the ARM template to deploy the Web App. But I am getting the below error while performing the deployment.
I used JSON Lint, to validate the JSON and looks like it is fine. The error code tells me that there is an issue with the parameter file's syntax, but I am not able to pinpoint it. I tried many things to debug this but not able to fix it.
Error:
PS C:\Users\manjug\Desktop> New-AzResourceGroupDeployment `
-Name 'test01' `
-ResourceGroupName ITQIG-eu-manjug-windows-app `
-TemplateParameterUri C:\Users\manjug\Desktop\azuredeploy_webapp.parameters.json `
-TemplateUri C:\Users\manjug\Desktop\azuredeploy_webapp.json `
-Verbose
VERBOSE: Performing the operation "Creating Deployment" on target "ITQIG-eu-manjug-windows-app".
New-AzResourceGroupDeployment : 2:22:59 PM - Error: Code=InvalidTemplate; Message=Deployment template validation failed: 'The value for the template parameter 'appName' at line '7' and
column '20' is not provided. Please see https://aka.ms/resource-manager-parameter-files for usage details.'.
At line:1 char:1
+ New-AzResourceGroupDeployment `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-AzResourceGroupDeployment], Exception
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet
New-AzResourceGroupDeployment : The deployment validation failed
At line:1 char:1
+ New-AzResourceGroupDeployment `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzResourceGroupDeployment], InvalidOperationException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet
azuredeploy_webapp.parameter.json:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appName": {
"value": "ITQIG-eu-web-manju123"
},
"kind": {
"value": "app"
},
"location": {
"value": "west europe"
},
"subnetResourceID": {
"value": "/subscriptions/7e7f55d3-4bfd-a6be-1c59594b8592/resourceGroups/ITQIG-eu-network-dev/providers/Microsoft.Network/virtualNetworks/ITQIG-eu-vnet-dev/subnets/subnet7-AWmanjug"
},
"appServicePlanResourceID": {
"value": "/subscriptions/7e7f55d3-4bfd-a6be-1c59594b8592/resourceGroups/ITQIG-eu-manjug-windows-app/providers/microsoft.web/serverFarms/eu-manjug-windows-plan"
}
}
}
azuredeploy_webapp.json
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appName": {
"type": "string",
"metadata": {
"description": "The name of the app to create."
}
},
"kind": {
"type": "string",
"metadata": {
"description": "Web app kind. OS type -> Windows / Linux."
}
},
"appServicePlanResourceID": {
"metadata": {
"description": "The resource ID of the app service plan."
},
"type": "string"
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "The location in which all resources should be deployed."
}
},
"subnetResourceID": {
"type": "string",
"metadata": {
"description": "The subnet resource ID created for app service plan which contains this web app."
}
}
},
"resources": [
{
"type": "Microsoft.Web/sites",
"apiVersion": "2019-08-01",
"name": "[parameters('appName')]",
"location": "[parameters('location')]",
"kind": "[parameters('kind')]",
"properties": {
"serverFarmId": "[parameters('appServicePlanResourceID')]"
},
"resources": [
{
"name": "virtualNetwork",
"type": "networkConfig",
"apiVersion": "2019-08-01",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', parameters('appName'))]"
],
"properties": {
"subnetResourceId": "[parameters('subnetResourceId')]",
"swiftSupported": true
}
}
]
}
]
}
I deleted the old file and re-created a new JSON file with the same contents. It is working now. I do not know what caused the issue with the old file though..
It looks like the issue is a result of the powershell cmdlet parameters you were using and not your templates/parameters. Try the following:
Use TemplateParameterFile instead of TemplateParameterUri
Use TemplateFile instead of TemplateUri
Use the file parameters for non uri based arm deployments and this should fix your issue. https://learn.microsoft.com/en-us/powershell/module/az.resources/new-azresourcegroupdeployment?view=azps-4.5.0
Your problem I think is because you are providing dependencies on an existing resource. Remove the "serverFarmId": "[parameters('appServicePlanResourceID')]".
Also another to fix is the hardcoding values of the resourceId you have in parameters file.
We are upgrading our Data pipeline version from 3.3.2 to 5.8, so those bootstrap actions on old AMI release have changed to be setup using configuration and specifying them under classification / property definition.
So my Json looks like below
{
"enableDebugging": "true",
"taskInstanceBidPrice": "1",
"terminateAfter": "2 Hours",
"name": "ExportCluster",
"taskInstanceType": "m1.xlarge",
"schedule": {
"ref": "Default"
},
"emrLogUri": "s3://emr-script-logs/",
"coreInstanceType": "m1.xlarge",
"coreInstanceCount": "1",
"taskInstanceCount": "4",
"masterInstanceType": "m3.xlarge",
"keyPair": "XXXX",
"applications": ["hadoop","hive", "tez"],
"subnetId": "XXXXX",
"logUri": "s3://pipelinedata/XXX",
"releaseLabel": "emr-5.8.0",
"type": "EmrCluster",
"id": "EmrClusterWithNewEMRVersion",
"configuration": [
{ "ref": "configureEmrHiveSite" }
]
},
{
"myComment": "This object configures hive-site xml.",
"name": "HiveSite Configuration",
"type": "HiveSiteConfiguration",
"id": "configureEmrHiveSite",
"classification": "hive-site",
"property": [
{"ref": "hive-exec-compress-output" }
]
},
{
"myComment": "This object sets a hive-site configuration
property value.",
"name":"hive-exec-compress-output",
"type": "Property",
"id": "hive-exec-compress-output",
"key": "hive.exec.compress.output",
"value": "true"
}
],
"parameters": []
With the above Json file it gets loaded into Data Pipeline but throws an error saying
Object:HiveSite Configuration
ERROR: 'HiveSiteConfiguration'
Object:ExportCluster
ERROR: 'configuration' values must be of type 'null'. Found values of type 'null'
I am not sure what this really means and could you please let me know if i am specifying this correctly which i think i am according to http://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-configure-apps.html
The below block should have the name as "EMR Configuration" only then its recognized correctly by the AWS Data pipeline and the Hive-site.xml is being set accordingly.
{
"myComment": "This object configures hive-site xml.",
"name": "EMR Configuration",
"type": "EmrConfiguration",
"id": "configureEmrHiveSite",
"classification": "hive-site",
"property": [
{"ref": "hive-exec-compress-output" }
]
},
I am using a series of json ARM templates to deploy Azure VMs, and am having issues passing information from one resource deployment to another.
I deploy two resources using linked templates from blob storage, one which in and of itself deploys nothing, but returns an object populated with configuration settings, and a second which then passes that output of configuration settings to another template as a parameter:
"resources": [
{
"name": "[concat(deployment().name, '-config')]",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2016-09-01",
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[variables('configurationTemplate')]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"subscriptionParameters": { "value": "[variables('subscriptionParameters')]" }
}
}
},
{
"name": "[concat(deployment().name, '-vm')]",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2016-09-01",
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[variables('vmTemplate')]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"configuration": { "value": "[reference(concat(deployment().name, '-config').outputs.configuration.value)]" },
"vmName": { "value": "[parameters('vmName')]" },
"vmSize": { "value": "[parameters('vmSize')]" },
"os": { "value": "[parameters('os')]" },
"managedDiskTier": { "value": "[parameters('managedDiskTier')]" },
"dataDisksToProvision": { "value": "[parameters('dataDisksToProvision')]" },
"dataDiskSizeGB": { "value": "[parameters('dataDiskSizeGB')]" },
"domainJoined": { "value": "[parameters('domainJoined')]" },
"localAdminUsername": { "value": "[parameters('localAdminUsername')]" },
"localAdminPassword": { "value": "[parameters('localAdminPassword')]" },
"numberOfNics": { "value": "[parameters('numberOfNics')]" },
"subnetName": { "value": "[parameters('subnetName')]" },
"highlyAvailable": { "value": "[parameters('highlyAvailable')]" },
"availabilitySetName": { "value": "[parameters('availabilitySetName')]" },
"availabilitySetUpdateDomains": { "value": "[parameters('availabilitySetUpdateDomains')]" },
"availabilitySetFaultDomains": { "value": "[parameters('availabilitySetFaultDomains')]" }
}
}
}
],
"outputs": {
"configuration": {
"type": "object",
"value": "[reference(concat(deployment().name, '-config')).outputs.configuration.value]"
}
}
Deploying the first resource on it's own succeeds, and the output [reference(concat(deployment().name, '-config')).outputs.configuration.value] is correctly returned, and contains all the correct information and is well formed.
If I then add the second resource into the mix, then the deployment fails with
the following error:
08:57:41 - [ERROR] New-AzureRmResourceGroupDeployment : 08:57:41 - Error: Code=InvalidTemplate;
08:57:41 - [ERROR] Message=Deployment template validation failed: 'The template resource
08:57:41 - [ERROR] 'rcss.test.vm-0502-0757-rcss-vm' at line '317' and column '6' is not valid:
08:57:41 - [ERROR] The language expression property 'Microsoft.WindowsAzure.ResourceStack.Frontdoo
08:57:41 - [ERROR] r.Expression.Expressions.JTokenExpression' can't be evaluated.. Please see
08:57:41 - [ERROR] https://aka.ms/arm-template-expressions for usage details.'.
If I remove the "configuration" parameter from both this parameter set and from the referenced template (the referenced template has all contents commented out to ensure we are testing only the pass-through of the parameters), then the deployment succeeds, indicating that the issue is related to the parsing of the parameter string "[reference(concat(deployment().name, '-config').outputs.configuration.value)]".
Can anyone offer any insight as to whether I need to refer to output objects from deployment resources in a specific way in the context of a linked template parameter set?
So after examining this more closely, I found that the syntax I was using was incorrect, but not reported by the parser:
"[reference(concat(deployment().name, '-config').outputs.configuration.value)]"
Should have been:
"[reference(concat(deployment().name, '-config')).outputs.configuration.value]"
Schoolboy error.
I'm trying to conditionally provide resource property values through translation of runtime resource properties within a copyIndex loop..
Upon deploying the following ARM template, I receive the error:
Unable to process template language expressions for resource '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{vm-name}/extensions/Microsoft.EnterpriseCloud.Monitoring' at line '30' and column '10'. 'The template resource '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{vm-name}' is not found.' (Code: InvalidTemplate)
"type": "[variables('extensionType')[reference(concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachines')[copyIndex()].name)).storageProfile.osDisk.osType]]",
However, the VM exists with the ID it provides, so it doesn't make sense that the engine cannot find it. If I hard-code the Extension Type, there are no errors and the Extension is installed on the VM with the same ID.
Unfortunately, I don't know if this is a bug within ARM or if I'm just doing something wrong..
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"workspaceResourceId": { "type": "string" },
"virtualMachines": { "type": "array" }
},
"variables": {
"extensionType": {
"Windows": "MicrosoftMonitoringAgent",
"Linux": "OmsAgentForLinux"
}
},
"resources": [
{
"copy": {
"name": "VMMonitoringExtensionsCopy",
"count": "[length(parameters('virtualMachines'))]"
},
"type": "Microsoft.Compute/virtualMachines/extensions",
"apiVersion": "2015-05-01-preview",
"location": "[parameters('virtualMachines')[copyIndex()].location]",
"name": "[concat(parameters('virtualMachines')[copyIndex()].name, '/Microsoft.EnterpriseCloud.Monitoring')]",
"properties": {
"publisher": "Microsoft.EnterpriseCloud.Monitoring",
"type": "[variables('extensionType')[reference(concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachines')[copyIndex()].name)).storageProfile.osDisk.osType]]",
"typeHandlerVersion": "1.0",
"autoUpgradeMinorVersion": true,
"settings": {
"workspaceId": "[reference(parameters('workspaceResourceId'), '2015-11-01-preview').customerId]"
},
"protectedSettings": {
"workspaceKey": "[listKeys(parameters('workspaceResourceId'), '2015-11-01-preview').primarySharedKey]"
}
}
}
]
}
The object array being passed in for virtualMachines looks like this:
[
{ "name": "vm-name", "location": "azure-region" }
]
A couple things you can try:
1) Assuming the VM is not defined in the same template try using the "full" resourceId in the reference function. See the last example in this doc:
https://azure.microsoft.com/en-us/documentation/articles/resource-group-template-functions/#reference - it seems like the error already knows the full resourceId, but it's worth trying
2) the other thought is that the reference function is evaluated at runtime and the resource provider doesn't like the expression but that's a swag.
I will do some more poking and see if we can't nail this down.