question

BelousNikolay-7383 avatar image
0 Votes"
BelousNikolay-7383 asked tbgangav-MSFT commented

Multiline script inside the arm template json blueprint artifact's deployment script

Are the arm template's deployment scripts, that integrated into Azure Blueprint support multiline scripts anyhow?

I mean.... like this

 {
       "$schema": "https://schema.management.azure.com/schemas/2019-08-01/deploymentTemplate.json#",
       "contentVersion": "1.0.0.0",
   "parameters": {
     "First": {
       "type": "String"
     },
     "Second": {
       "type": "String"
     }
   },
       "resources": [
         {
           "type": "Microsoft.Resources/deploymentScripts",
           "apiVersion": "2020-10-01",
           "name": "demoSample",
           "location": "[resourceGroup().location]",
           "identity": {
             "type": "UserAssigned",
             "userAssignedIdentities": {
               "/subscriptions/xxxxxx/resourceGroups/xxxxxxxxxxx/providers/Microsoft.ManagedIdentity/userAssignedIdentities/xxxxxxxxxxxx": {
               }
             }
           },
           "kind": "AzureCLI",
           "properties": {
             "azCliVersion": "2.9.1",
             "timeout": "PT30M",
             "scriptContent": "
                     Command1
                     Command2
                     Command3
               ",
             "cleanupPreference": "OnSuccess",
             "retentionInterval": "P1D"
           }
         }
       ]
       }

, but not:


 {
       "$schema": "https://schema.management.azure.com/schemas/2019-08-01/deploymentTemplate.json#",
       "contentVersion": "1.0.0.0",
   "parameters": {
     "First": {
       "type": "String"
     },
     "Second": {
       "type": "String"
     }
   },
       "resources": [
         {
           "type": "Microsoft.Resources/deploymentScripts",
           "apiVersion": "2020-10-01",
           "name": "demoSample",
           "location": "[resourceGroup().location]",
           "identity": {
             "type": "UserAssigned",
             "userAssignedIdentities": {
               "/subscriptions/xxxxxx/resourceGroups/xxxxxxxxxxx/providers/Microsoft.ManagedIdentity/userAssignedIdentities/xxxxxxxxxxxx": {
               }
             }
           },
           "kind": "AzureCLI",
           "properties": {
             "azCliVersion": "2.9.1",
             "timeout": "PT30M",
             "scriptContent": "Command1; Command2; Command3",
             "cleanupPreference": "OnSuccess",
             "retentionInterval": "P1D"
           }
         }
       ]
       }


Or the only way is to shape it as a VERY LONG SINGLE LINE?
I'm literally stuck with the problem. Single line deployment scripts are very useful anyway, but they look horrible! For the classical arm json template + parameters json file + deployment using New-AzResourceGroupDeployment cmdlet, multiline scripts work just fine, BUT for arm json templates inside the blueprint, I couldn't make it working.

azure-blueprints
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

tbgangav-MSFT avatar image
0 Votes"
tbgangav-MSFT answered tbgangav-MSFT commented

Hi @BelousNikolay-7383,

As mentioned in this official Azure document, currently the Azure portal and Azure DevOps pipeline can't parse a deployment script with multiple lines. You can either chain the PowerShell commands (by using semicolons or \r\n or \n) into one line, or use the primaryScriptUri property with an external script file.

For illustration, please find below screenshot that's taken from above mentioned official Azure document.

101233-image.png


image.png (145.4 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Any chance for improvements? Deployment scripts are a very useful feature, but online scripts are horrible.
Using primaryScriptUri makes everything more complicated and less IaaC.

0 Votes 0 ·

Hi @BelousNikolay-7383,

AFAIK, no changes are being planned w.r.t it in the very near future. But, I will share this improvement feedback with the internal product team and will keep you updated as I hear more information. However, on the other hand, I recommend you to share this improvement feedback over here in this ARM related uservoice / feedback forum. In general, Azure feature or product team would check feasibility of a feature request, prioritize against existing feature backlog, add in roadmap as appropriate and would announce and/or update the related Azure document once a feature request is addressed.

0 Votes 0 ·