-
Notifications
You must be signed in to change notification settings - Fork 191
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
Arm-ttk failing the usage of concat() in ARM-templates #590
Comments
I suspect that's intentional - can you share the template (or resource snippet)? |
We are facing a similar issue that only started today. Here's an Example.... ERROR MESSAGE STACK TRACE Here's a snippet of the ARM template showing the use of concat().
|
@riclandy - any chance you could attach (or send me) a complete template? I know ADF/Datbricks can be a bit unwieldy but I'm not able to repro the stack trace with just your snippet above. The flagging of the concat function is expected... |
We ran into this as well, but in our case they were valid test failures. We just didn't realize a new test had been added and when it started failing in CI it caught us off guard. Example snippet of the change to pass the test: "uri": "[concat('https://mystorageaccount.blob.', environment().suffixes.storage, '/templates/v2/')]" Passes "uri": "[uri(concat('https://mystorageaccount.blob.', environment().suffixes.storage), '/templates/v2/')]" |
@erik-source @bmoore-msft |
@erik-source and @bmoore-msft Therefore, if I need to use the URI function I have to pass in 2 values. This works but leaves me with a trailing '/' , which I don't need in the ARM template. For example, This example, also passed the test but the URL function adds a trailing '/' Is this the best way to focus on fixing the proper constructed url and uri's ? |
That is a good point, the docs for the I noticed in one of the passing test cases a dot is used as the second parameter. I'm not an expert at URIs by any means but I suppose that's still a valid DNS name, albeit not a common pattern. And maybe I'm totally misinterpreting the usage of the dot there. It would be easier to have the tests allow for URIs without path segments, but still need interpolation/format/concat. The DeploymentTemplate-Must-Not-Contain-Hardcoded-Uri test checks for this, so I imagine it will be very common. |
I believe the trailing slash is part of the canonical representation of the URI - any code that deals with a uri would take that into account, any string manipulation would have to "manually". Is the problem that you don't want/need the trailing slash or something in ARM doesn't allow it (which wouldn't surprise me). Aside from that I'm not sure what we could do in the test, that would account for both cases - so the only option may be to skip it. |
Thanks for the speedy replies! We've decided to go the the trailing forward slash. It's working OK, the Arm-Ttk tests are all passing and the ARM templates are deploying without any errors. So far, so good. |
@bmoore-msft I think the only issue in our case is that we don't want/need it. If we don't need to combine a base and relative uri, I wouldn't expect to have to call the As you say, the result is still a valid uri and it has not broken anything for us. If this can't be accounted for in the test, I suppose we just have to deal with this quirk when writing our templates. |
I also have issue with trailing slash in uri() function. Solved by using variables, instead of using "catalogUri": "[concat(variables('purviewAccountName'), '.catalog.purview.azure.com')]" I added variable: "variables": {
"catalogHost": "[concat(variables('purviewAccountName'), '.catalog.purview.azure.com')]"
} and used it in resource parameter: "catalogUri": "[variables('catalogHost')]" |
We might be able to get creative and check to see if it's just a hostName you're after... e.g. is the last arguement in the function fit a regex that looks like a TLD (...) of something like that... Would have to think through it a bit to see if that has unintended consequences -- would also be a breaking change... but I do agree with the scenario. A hostname and a URI are arguably different things. |
We have faced an issue while using the Arm-ttk runner to static scan some of the ARM-templates which were infact exported from the Azure portal it self and directly used, which contains concat() in some of the URI attributes. Following is the failure message which shows in the Pipeline run logs.
[-] URIs Should Be Properly Constructed (51 ms)
Function'concat' found within 'iconUri Line: 45, Column: 3533
Function'concat' found within 'requestUri Line: 52, Column: 4575
The text was updated successfully, but these errors were encountered: