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

API connection needs to support connectionRuntimeUrl as output/property #2192

Open
brandonh-msft opened this issue Jul 6, 2021 · 10 comments

Comments

@brandonh-msft
Copy link
Member

Bicep version

$ az bicep version
Bicep CLI version 0.4.63 (7ebed03284)

Describe the bug

I'm creating an API Connection resource in Azure so that I can then use its Runtime URL in a Logic App connection. However, I'm unable to get the runtime URL despite it being available on the API Connection resource's output from az cli

To Reproduce
Steps to reproduce the behavior:

resource tableStorageConnection 'Microsoft.Web/connections@2016-06-01' = {
  name: 'tablestorage'
  location: resourceGroup().location
  properties: {
    displayName: 'tablestorage'
    api: {
      id: '/subscriptions/${subscription().subscriptionId}/providers/Microsoft.Web/locations/${resourceGroup().location}/managedApis/azuretables'
    }
  }
  tags: tags
}

now try to get the connectionRuntimeUrl property off the created Azure resource as shown by az resource show --ids <connection resource ID>:

  "properties": {
    "api": {
      "brandColor": "#804998",
      "category": "Standard",
      "description": "Azure Table storage is a service that stores structured NoSQL data in the cloud, providing a key/attribute store with a schemaless design. Sign into your Storage account to create, update, and query tables and more.",
      "displayName": "Azure Table Storage",
      "iconUri": "https://connectoricons-prod.azureedge.net/releases/v1.0.1479/1.0.1479.2452/azuretables/icon.png",
      "id": "/subscriptions/xxxxx/providers/Microsoft.Web/locations/westus2/managedApis/azuretables",
      "name": "azuretables",
      "type": "Microsoft.Web/locations/managedApis"
    },
    "authenticatedUser": {},
    "changedTime": "2021-07-06T21:25:02.8856356Z",
    "connectionRuntimeUrl": "https://xxxxx.common.logic-westus2.azure-apihub.net/apim/azuretables/xxxxx",
    "createdTime": "2021-07-06T21:25:02.8856356Z",
    "customParameterValues": {},
    "displayName": "tablestorage",
    "nonSecretParameterValues": {
      "storageaccount": "default"
    },

I tried by using

tableStorageConnection.properties.connectionRuntimeUrl and tableStorageConnection.properties['connectionRuntimeUrl']

and am met with the following warning in the CLI during deployment

/main.bicep(54,54) : Warning BCP053: The type "schemas:30_properties" does not contain property "connectionRuntimeUrl". Available properties include "api", "changedTime", "createdTime", "customParameterValues", "displayName", "nonSecretParameterValues", "parameterValues", "statuses", "testLinks".

but the deployment then fails in Azure with the same message:
image

(Secondary complaint: if it's going to fail the deployment, then bicep should error, not warn)

Bicep's compiled JSON looks like this:

  // where I'm trying to use the value
            {
              "name": "azuretables_runtimeUrl",
              "value": "[reference(resourceId('Microsoft.Web/connections', 'tablestorage')).connectionRuntimeUrl]"
            },
...
    {
      "type": "Microsoft.Web/connections",
      "apiVersion": "2016-06-01",
      "name": "tablestorage",
      "location": "[resourceGroup().location]",
      "properties": {
        "displayName": "tablestorage",
        "api": {
          "id": "[format('/subscriptions/{0}/providers/Microsoft.Web/locations/{1}/managedApis/azuretables', subscription().subscriptionId, resourceGroup().location)]"
        }
      },
      "tags": "[parameters('tags')]"
    }
@majastrz
Copy link
Member

majastrz commented Jul 6, 2021

This may be an issue with the resource provider. When the runtime evaluates the expression "[reference(resourceId('Microsoft.Web/connections', 'tablestorage')).connectionRuntimeUrl]", it will perform a GET on the specific resource. If the RP doesn't make the connectionRuntimeUrl property available immediately after the initial PUT succeeds and returns a response on the GET without the property, it would explain the failure.

@brandonh-msft
Copy link
Member Author

brandonh-msft commented Jul 7, 2021

How can we get this equivalent in bicep?

            {
              "name": "azuretables_runtimeUrl",
              "value": "[reference(resourceId('Microsoft.Web/connections', 'tablestorage', 'full')).connectionRuntimeUrl]"
            },

(note the 'full' param added to the resourceId function)

@alex-frankel
Copy link
Collaborator

'full' is not an argument that is supported on the resourceId() function, it is an argument of the reference() function, but that is not the issue. The resource does not appear to return the connectionRuntimeUrl property on a GET request. My guess is the CLI is doing multiple calls, not just a simple GET request to grab this value. The right next step is to reach out to the Web RP team as to how/why they are doing this, and if they can start returning it in a GET. Any chance you can open a support request for this? Otherwise, we can discuss this during our monthly sync with that team on 7/21.

@brandonh-msft
Copy link
Member Author

'full' is not an argument that is supported on the resourceId() function, it is an argument of the reference() function, but that is not the issue. The resource does not appear to return the connectionRuntimeUrl property on a GET request. My guess is the CLI is doing multiple calls, not just a simple GET request to grab this value. The right next step is to reach out to the Web RP team as to how/why they are doing this, and if they can start returning it in a GET. Any chance you can open a support request for this? Otherwise, we can discuss this during our monthly sync with that team on 7/21.

Thanks for that detail; unfortunately, I'm headed out of the office until the 18th and probably wouldn't know the right verbiage/people as well as you/your team. If you want to include me in the call on the 21st that'd be great - I'll see if I can make it.

@brandonh-msft
Copy link
Member Author

brandonh-msft commented Jul 7, 2021

Also, please review usage in ARM here which works fine (I just botched my c/p)

@alex-frankel
Copy link
Collaborator

I think I figured this one out. There are at least two issues:

  1. There is an undeclared top level property kind which needs a value of v2 in order for this property to be emitted. We are more strict with top-level properties in bicep, so the fact that this property is missing from the type is treated as an error, which will prevent you from deploying this bicep code. This is another case for prioritizing Relax missing top-level resource property validations to 'warning' bicep#3000.
  2. The property connectionRuntimeUrl is also missing. I suspect this is because the property didn't get introduced until the kind: 'v2' value existed.

Both of these problems should be properly fixed in a single swagger update. I'm not sure how quickly that will get done, so Azure/bicep#3000 will have to serve as a stop-gap in the meantime. Unfortunately, you are blocked on doing this in Bicep until that is done. cc @miqm as FYI since I know he was looking into implementing this.

@brandonh-msft
Copy link
Member Author

brandonh-msft commented Jul 7, 2021

Yup i just filed Azure/bicep#3512 as part of trying to figure this out. My workaround is to bicep build the file then sed the output JSON to add the "kind" property

@skyaddict
Copy link

skyaddict commented Aug 20, 2021

This is maybe helpful to someone else. If you already have a connection created named "myConnection" you will get the following error if you try to change the kind to V2. Delete the resource first then try the creation again.

{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.","details":[{"code":"ConnectionV2KindMismatch","message":"The 'kind' property in api connection '' cannot be changed from 'V1' to 'V2'."}]}

@Wittionary
Copy link

This is still an issue.

@alex-frankel alex-frankel transferred this issue from Azure/bicep Jun 11, 2024
@kurt-mueller-osumc
Copy link

Still an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

6 participants