I'm creating a Template Spec using Bicep, which works fine. Adding a custom UI to the Template Spec using a uiFormDefinition file also works. However, when I try to use the control 'Microsoft.Solutions.ArmApiControl' in the UI definition, it fails with the error Failed to create element of type: 'Microsoft.Solutions.ArmApiControl' named 'sqlCapabilities'
. I found that I can get rid of the error by removing all referencing functions from the path
property, like this:
{
"name": "sqlCapabilities",
"type": "Microsoft.Solutions.ArmApiControl",
"request": {
"method": "GET",
"path": "/subscriptions/34d76722-9b63-464d-b742-11bf072d1fc1/providers/Microsoft.Sql/locations/westeurope/capabilities?api-version=2021-11-01"
}
}
... but that doesn't actually seems to do anything. (And even if this would work the element wouldn't be very useful without referencing functions.)
While reading the documentation, I noticed there are two sandboxes in the Azure Portal for developing uiFormDefinition files:
- https://portal.azure.com/#view/Microsoft_Azure_CreateUIDef/FormSandboxBlade (titled "Form view Sandbox"), which is linked to from the Create portal form page of the ARM template documentation using the shortlink https://aka.ms/form/sandbox.
- https://portal.azure.com/#view/Microsoft_Azure_CreateUIDef/SandboxBlade (titled "Create UI Definition Sandbox"), which is linked to from the Create portal interface page of the Azure Managed Applications Documentation.
They look similar, but they use different schemas: the UI Definition sandbox uses https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#
and the Form sandbox uses https://schema.management.azure.com/schemas/2021-09-09/uiFormDefinition.schema.json
. The Form sandbox also has a few additional options such as the ability to specify the "Package Type" and "CUID".
Both sandboxes have a list documenting UI elements, which both point to the same destination: the Azure Managed Applications documentation.
The thing is: when I use the "Create UI Definition Sandbox" the 'Microsoft.Solutions.ArmApiControl' UI element works fine, even when using referencing functions like location()
. However, I can't use the resulting file with the Template Spec: it attaches OK but when trying to deploy the Template Spec in the Portal I get this error: Invalid UIFormDefinition Schema. Click here to fallback to default experience.
Using referencing functions and/or 'Microsoft.Solutions.ArmApiControl' in the "Form view Sandbox" results in the problems mentioned at the beginning of this question.
Experimenting further, it looks like all functions work in both sandboxes, with the exception of referencing functions like location()
, resourceGroup()
orsubscription()
: those only appear to work in the UI definition sandbox. The same applies to some UI elements.
Perhaps I missed it, but I wasn't able to find where this behavior is documented.
Is there a way to use the referencing functions and Microsoft.Solutions.ArmApiControl in a form definition for a Template Spec? If so, how can I do that?
CodePudding user response:
TL;DR - you can do what you want, take a look at this: https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-azure-templatespecs-with-a-custom-ui/ba-p/3586173
Long version, there are 2 schemas/formats for portal ui (as you discovered), there is an "old" version CreateUIDefinition.MultiVm.json
and a newer version uiFormDefinition.schema.json
- the newer version is largely a superset of the old version... i.e. it supports all the old stuff and has some new stuff. This distinction is not well documented yet.
templateSpecs only support the "newer" schema.
That help?