Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support extended JSON format for ARM templates #560

Open
freastro opened this issue Jul 7, 2021 · 0 comments
Open

Support extended JSON format for ARM templates #560

freastro opened this issue Jul 7, 2021 · 0 comments

Comments

@freastro
Copy link

freastro commented Jul 7, 2021

This is a Feature Proposal

Description

Azure supports an extended JSON format for its ARM templates that includes support for comments and multi-line strings. But these templates are not currently supported by Serverless Azure Functions due to using JSON.parse() which only supports the regular JSON format. I propose that the provider.armTemplate.file parameter should be extended to support any valid ARM template.

Examples

Here are some examples from the Azure docs of valid ARM templates that are not currently supported by Serverless Azure Functions.
https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/syntax

Comments

{
  "type": "Microsoft.Compute/virtualMachines",
  "apiVersion": "2018-10-01",
  "name": "[variables('vmName')]", // to customize name, change it in variables
  "location": "[parameters('location')]", //defaults to resource group location
  "dependsOn": [ /* storage account and network interface must be deployed first */
    "[resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]",
    "[resourceId('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
  ],

Multi-line strings

{
  "type": "Microsoft.Compute/virtualMachines",
  "apiVersion": "2018-10-01",
  "name": "[variables('vmName')]", // to customize name, change it in variables
  "location": "[
    parameters('location')
    ]", //defaults to resource group location
  /*
    storage account and network interface
    must be deployed first
  */
  "dependsOn": [
    "[resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]",
    "[resourceId('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
  ],jsonc

Error

Below is the current error message displayed when trying to use an ARM template that includes comments:

  SyntaxError: Unexpected token / in JSON at position 1164
      at JSON.parse (<anonymous>)
      at ArmService.createDeploymentFromConfig (node_modules/serverless-azure-functions/lib/services/armService.js:169:29)
      at FunctionAppService.<anonymous> (node_modules/serverless-azure-functions/lib/services/functionAppService.js:319:57)
      at step (node_modules/serverless-azure-functions/lib/services/functionAppService.js:45:23)
      at Object.next (node_modules/serverless-azure-functions/lib/services/functionAppService.js:26:53)
      at node_modules/serverless-azure-functions/lib/services/functionAppService.js:20:71
      at new Promise (<anonymous>)
      at __awaiter (node_modules/serverless-azure-functions/lib/services/functionAppService.js:16:12)
      at FunctionAppService.deploy (node_modules/serverless-azure-functions/lib/services/functionAppService.js:310:16)
      at AzureDeployPlugin.<anonymous> (node_modules/serverless-azure-functions/lib/plugins/deploy/azureDeployPlugin.js:143:65)
      at step (node_modules/serverless-azure-functions/lib/plugins/deploy/azureDeployPlugin.js:56:23)
      at Object.next (node_modules/serverless-azure-functions/lib/plugins/deploy/azureDeployPlugin.js:37:53)
      at fulfilled (node_modules/serverless-azure-functions/lib/plugins/deploy/azureDeployPlugin.js:28:58)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)
  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              14.17.0
     Framework Version:         2.50.0 (local)
     Plugin Version:            5.4.3
     SDK Version:               4.2.3
     Components Version:        3.13.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant