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

Array as output from template result as empty string. #20

Open
mrozenbeek opened this issue Dec 10, 2018 · 6 comments
Open

Array as output from template result as empty string. #20

mrozenbeek opened this issue Dec 10, 2018 · 6 comments

Comments

@mrozenbeek
Copy link

mrozenbeek commented Dec 10, 2018

When creating an Azure resource in this case a webapp it looks like a string array is not being set as a variable in the pipeline.

Example:

  • We have a frontend and a webAPI, both webapp resources. We output a string array in the webapp template we use. This array contains hostnames we use in the webAPI to set some settings.

When i debug the ARM Output task for the frontend i see that the array output is set as empty string, Is the array type supported? If so how do i use it? Good to mention that there is also no option to access the array by index.

Task:

image

Outputs from the template:
image
Where "webUrl" is the one that causes issues and "defaultUrl" is our temporary fix. Only we will surely get multiple host names and want to use the array.

Hopefully you can help me,

Greetings Michael

@mrozenbeek mrozenbeek reopened this Dec 10, 2018
@mrozenbeek mrozenbeek changed the title Array output String Array as output from template result as empty string. Dec 10, 2018
@mrozenbeek mrozenbeek changed the title String Array as output from template result as empty string. Array as output from template result as empty string. Dec 10, 2018
@keesschollaart81
Copy link
Owner

Starting with #21 Arrays are now a supported output.
An array like this will result in outputs like:

Updating Azure Pipelines variable 'arrayTest_0'
Updating Azure Pipelines variable 'arrayTest_1'

Let me know if I missed anything here!

@mrozenbeek
Copy link
Author

Hi @keesschollaart81 thanks for the reply. I can't use the suggestion you made. We need the entire array itself since we do not know the size beforehand.

@keesschollaart81
Copy link
Owner

keesschollaart81 commented Dec 28, 2018

Hi, yes that should be possible. Basically it threads the array the same a complex type/object. It flattens it, for array's without keys an indexer will be used. more here. I suggest that you try it with the v5 with the 'System.Debug' variable set to true and lets use the output of the log in this discussion!

@mrozenbeek
Copy link
Author

mrozenbeek commented Dec 28, 2018

Since we needed a quick fix we added a single url as output called 'defaultUrl' :
image

We have 2 webapps one is A and other one is B. A outputs a array of hostnames we use as input for CORS settings in B. Now we see in the deployments from A that the output from the template is correct.

Output in resource group deployments:
image

WebUrl is an array of hostnames and defaultUrl is for now the first hostname.

Debug ARM output:
tasklog_7.log

I see an empty value for the array and the string value "defaultUrl" gets filled in and works. I use a prefix name "webapp" since i have multiple tasks.

Hope this helps. Thanks in advance

@keesschollaart81
Copy link
Owner

You're on the old v4.0.x version of the task. Please update and share the log! :-) (you can check/select the version you're using at the top of the task-form)

@mrozenbeek
Copy link
Author

Log from version 5:
2018-12-28T14:58:16.6229136Z ##[debug]Evaluating condition for step: 'ARM Outputs'
2018-12-28T14:58:16.6229995Z ##[debug]Evaluating: succeeded()
2018-12-28T14:58:16.6230177Z ##[debug]Evaluating succeeded:
2018-12-28T14:58:16.6230438Z ##[debug]=> True
2018-12-28T14:58:16.6230744Z ##[debug]Result: True
2018-12-28T14:58:16.6231020Z ##[section]Starting: ARM Outputs
2018-12-28T14:58:16.6236475Z ==============================================================================
2018-12-28T14:58:16.6236599Z Task : ARM Outputs
2018-12-28T14:58:16.6236712Z Description : This task reads the output values of an ARM deployment and sets them as Azure Pipelines variables.
2018-12-28T14:58:16.6236796Z Version : 5.0.19
2018-12-28T14:58:16.6236892Z Author : Kees Schollaart
2018-12-28T14:58:16.6236971Z Help : More Information
2018-12-28T14:58:16.6237093Z ==============================================================================
2018-12-28T14:58:17.1149903Z ##[debug]agent.TempDirectory=C:\BuildAgents\BuildAgent1_work_temp
2018-12-28T14:58:17.1234895Z ##[debug]loading inputs and endpoints
2018-12-28T14:58:17.1240715Z ##[debug]loading ENDPOINT_AUTH_6521dedc-191b-4905-8187-cae8cf840c26
2018-12-28T14:58:17.1254306Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_6521dedc-191b-4905-8187-cae8cf840c26_AUTHENTICATIONTYPE
2018-12-28T14:58:17.1258277Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_6521dedc-191b-4905-8187-cae8cf840c26_SERVICEPRINCIPALID
2018-12-28T14:58:17.1259876Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_6521dedc-191b-4905-8187-cae8cf840c26_SERVICEPRINCIPALKEY
2018-12-28T14:58:17.1261911Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_6521dedc-191b-4905-8187-cae8cf840c26_TENANTID
2018-12-28T14:58:17.1265075Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2018-12-28T14:58:17.1267641Z ##[debug]loading ENDPOINT_AUTH_SCHEME_6521dedc-191b-4905-8187-cae8cf840c26
2018-12-28T14:58:17.1269598Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2018-12-28T14:58:17.1271671Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2018-12-28T14:58:17.1279433Z ##[debug]loading INPUT_CONNECTEDSERVICENAMEARM
2018-12-28T14:58:17.1291537Z ##[debug]loading INPUT_CONNECTEDSERVICENAMESELECTOR
2018-12-28T14:58:17.1294126Z ##[debug]loading INPUT_PREFIX
2018-12-28T14:58:17.1298157Z ##[debug]loading INPUT_RESOURCEGROUPNAME
2018-12-28T14:58:17.1301812Z ##[debug]loading INPUT_WHENLASTDEPLOYMENTISFAILED
2018-12-28T14:58:17.1319566Z ##[debug]loaded 14
2018-12-28T14:58:17.1349230Z ##[debug]Agent.ProxyUrl=undefined
2018-12-28T14:58:17.1350681Z ##[debug]Agent.CAInfo=undefined
2018-12-28T14:58:17.1350852Z ##[debug]Agent.ClientCert=undefined
2018-12-28T14:58:17.1351034Z ##[debug]Agent.SkipCertValidation=undefined
2018-12-28T14:58:18.0481017Z ##[debug]arm-outputs-notelemetry=undefined
2018-12-28T14:58:18.0482033Z ##[debug]ConnectedServiceNameARM=6521dedc-191b-4905-8187-cae8cf840c26
2018-12-28T14:58:18.0482301Z 6521dedc-191b-4905-8187-cae8cf840c26 exists true
2018-12-28T14:58:18.0482755Z ##[debug]6521dedc-191b-4905-8187-cae8cf840c26 exists true
2018-12-28T14:58:18.0483016Z ##[debug]6521dedc-191b-4905-8187-cae8cf840c26 data SubscriptionId = 38722994-388b-41c2-b6a2-2db56f9d4291
2018-12-28T14:58:18.0483232Z ##[debug]resourceGroupName=ARMOUPUTTEST
2018-12-28T14:58:18.0483411Z ##[debug]prefix=webapp
2018-12-28T14:58:18.0483543Z ##[debug]outputNames=null
2018-12-28T14:58:18.0483671Z ##[debug]whenLastDeploymentIsFailed=fail
2018-12-28T14:58:18.0483779Z ##[debug]deploymentNameFilter=null
2018-12-28T14:58:18.0483904Z ##[debug]System.Debug=true
2018-12-28T14:58:18.0484450Z ##[warning]You are running in debug mode (variable System.Debug is set to true), the values of your ARM Outputs will be printed to the log. If your deployment outputs any secret values, they will be shown, be careful (especially with public projects)!
2018-12-28T14:58:18.0484873Z ##[debug]Processed: ##vso[task.issue type=warning;]You are running in debug mode (variable System.Debug is set to true), the values of your ARM Outputs will be printed to the log. If your deployment outputs any secret values, they will be shown, be careful (especially with public projects)!
2018-12-28T14:58:18.0486829Z Updating Azure Pipelines variable 'webappwebAppMsiResourceId'
2018-12-28T14:58:18.0489169Z ##[debug]set webappwebAppMsiResourceId=b377f9a2-5417-4b19-9bdf-727d5888fe76
2018-12-28T14:58:18.0490189Z ##[debug]Processed: ##vso[task.setvariable variable=webappwebAppMsiResourceId;issecret=false;]b377f9a2-5417-4b19-9bdf-727d5888fe76
2018-12-28T14:58:18.0490543Z Updating Azure Pipelines variable 'webappwebUrl_0'
2018-12-28T14:58:18.0490755Z ##[debug]set webappwebUrl_0=dev-w-armouputtest.azurewebsites.net
2018-12-28T14:58:18.0490993Z ##[debug]Processed: ##vso[task.setvariable variable=webappwebUrl_0;issecret=false;]dev-w-armouputtest.azurewebsites.net
2018-12-28T14:58:18.0491110Z Updating Azure Pipelines variable 'webappdefaultUrl'
2018-12-28T14:58:18.0491352Z ##[debug]set webappdefaultUrl=https://dev-w-armouputtest.azurewebsites.net
2018-12-28T14:58:18.0491704Z ##[debug]Processed: ##vso[task.setvariable variable=webappdefaultUrl;issecret=false;]https://dev-w-armouputtest.azurewebsites.net
2018-12-28T14:58:18.0491941Z ##[debug]arm-outputs-notelemetry=undefined
2018-12-28T14:58:18.0492090Z ##[debug]task result: Succeeded
2018-12-28T14:58:18.0492428Z ##[debug]Processed: ##vso[task.complete result=Succeeded;]
2018-12-28T14:58:18.4789890Z ##[section]Finishing: ARM Outputs

i do see webappwebUrl_0 but i can't just get the entire array by using "webappwebUrl". Is this by design? in version 4 i did not saw webappwebUrl_0 either.

I get this error in the template : There was an error while overriding 'corsSettings' parameter because of 'SyntaxError: Unexpected token $ in JSON at position 0', make sure it follows JavaScript Object Notation (JSON). Since it propably can't find a variable named "webappwebUrl".

If getting the entire array is not a feature than we know that and we will just use "defaultUrl".

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

2 participants