'TypeError: Cannot read property 'type' of undefined', make sure it follows JavaScript Object Notation (JSON)

101 Views Asked by At

My initial code was :

{
    "name": "[concat(parameters('factoryName'), '/MemoExtraction')]",
    "type": "Microsoft.DataFactory/factories/linkedServices",
    "apiVersion": "2018-06-01",
    "properties": {
        "annotations": [],
        "type": "AzureFunction",
        "typeProperties": {
            "functionAppUrl": "[parameters('MemoExtraction_properties_typeProperties_functionAppUrl')]",
            "functionKey": {
                "type": "SecureString",
                "value": "[parameters('MemoExtraction_functionKey')]"
                                                        
                                                    
                  
                                       
            },
            "authentication": "Anonymous"
        }
    },
    "dependsOn": []
                                                                              
     
},

I have pushed new code as:

{
    "name": "[concat(parameters('factoryName'), '/MemoExtraction')]",
    "type": "Microsoft.DataFactory/factories/linkedServices",
    "apiVersion": "2018-06-01",
    "properties": {
        "annotations": [],
        "type": "AzureFunction",
        "typeProperties": {
            "functionAppUrl": "[parameters('MemoExtraction_properties_typeProperties_functionAppUrl')]",
            "functionKey": {
                "type": "AzureKeyVaultSecret",
                "store": {
                    "referenceName": "Ls_AzureKeyVault",
                    "type": "LinkedServiceReference"
                },
                "secretName": "MemoKey"
            },
            "authentication": "Anonymous"
        }
    },
    "dependsOn": [
       "[concat(variables('factoryId'), '/linkedServices/Ls_AzureKeyVault')]"
    ]
},

I am getting the below error : enter image description here

I am not sure why I am getting this error while deployment. It should deploy successfully .

1

There are 1 best solutions below

0
Pratik Lad On

I created one Function Linked Service with Key vault and then exported the ARM template of my ADF like below:-

enter image description here

Exported the template of the above ADF pipeline with ADF resource like below:-

enter image description here

From the Exported ARM code file, I selected the below 2 codes and replaced the Data factory parameter to the new ADF name without any pipeline, For the Azure Function Linked service to get deployed in the new ADF pipeline like below:-

Exported ARM code:-

enter image description here

Added the above two files in my Azure repository and replaced the ADF name parameter with the new testadf90silicon name like below:-

ARMTemplateParametersForFactory.json

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "factoryName": {
            "value": "testadf90silicon"
        },
        "AzureKeyVault1_properties_typeProperties_baseUrl": {
            "value": "https://siliconkeyvault90.vault.azure.net/"
        },
        "AzureFunction1_properties_typeProperties_functionAppUrl": {
            "value": "https://siliconfunc65.azurewebsites.net"
        }
    }
}

ARMTemplateForFactory.json

{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "factoryName": {
            "type": "string",
            "metadata": "Data Factory name",
            "defaultValue": "testadf90silicon"
        },
        "AzureKeyVault1_properties_typeProperties_baseUrl": {
            "type": "string",
            "defaultValue": "https://siliconkeyvault90.vault.azure.net/"
        },
        "AzureFunction1_properties_typeProperties_functionAppUrl": {
            "type": "string",
            "defaultValue": "https://siliconfunc65.azurewebsites.net"
        }
    },
    "variables": {
        "factoryId": "[concat('Microsoft.DataFactory/factories/', parameters('factoryName'))]"
    },
    "resources": [
        {
            "name": "[concat(parameters('factoryName'), '/pipeline1')]",
            "type": "Microsoft.DataFactory/factories/pipelines",
            "apiVersion": "2018-06-01",
            "properties": {
                "activities": [
                    {
                        "name": "Azure Function1",
                        "type": "AzureFunctionActivity",
                        "dependsOn": [],
                        "policy": {
                            "timeout": "0.12:00:00",
                            "retry": 0,
                            "retryIntervalInSeconds": 30,
                            "secureOutput": false,
                            "secureInput": false
                        },
                        "userProperties": [],
                        "typeProperties": {
                            "functionName": "siliconfunc65",
                            "method": "GET",
                            "headers": {}
                        },
                        "linkedServiceName": {
                            "referenceName": "AzureFunction1",
                            "type": "LinkedServiceReference"
                        }
                    }
                ],
                "policy": {
                    "elapsedTimeMetric": {},
                    "cancelAfter": {}
                },
                "annotations": []
            },
            "dependsOn": [
                "[concat(variables('factoryId'), '/linkedServices/AzureFunction1')]"
            ]
        },
        {
            "name": "[concat(parameters('factoryName'), '/AzureKeyVault1')]",
            "type": "Microsoft.DataFactory/factories/linkedServices",
            "apiVersion": "2018-06-01",
            "properties": {
                "annotations": [],
                "type": "AzureKeyVault",
                "typeProperties": {
                    "baseUrl": "[parameters('AzureKeyVault1_properties_typeProperties_baseUrl')]"
                }
            },
            "dependsOn": []
        },
        {
            "name": "[concat(parameters('factoryName'), '/AzureFunction1')]",
            "type": "Microsoft.DataFactory/factories/linkedServices",
            "apiVersion": "2018-06-01",
            "properties": {
                "annotations": [],
                "type": "AzureFunction",
                "typeProperties": {
                    "functionAppUrl": "[parameters('AzureFunction1_properties_typeProperties_functionAppUrl')]",
                    "functionKey": {
                        "type": "AzureKeyVaultSecret",
                        "store": {
                            "referenceName": "AzureKeyVault1",
                            "type": "LinkedServiceReference"
                        },
                        "secretName": "secret",
                        "secretVersion": "cf004fc9796f40d1867c3647b76de797"
                    },
                    "authentication": "Anonymous"
                }
            },
            "dependsOn": [
                "[concat(variables('factoryId'), '/linkedServices/AzureKeyVault1')]"
            ]
        }
    ]
}

Output:-

Azure Function Linked Service Pipeline got created in new ADF:-

enter image description here

enter image description here

enter image description here

Also refer this similar SO thread by KarthikBhyresh-MT where you can override parameter for your function key and URI values.