2

I have a managed application that contains a button which invokes a POST request to the underlying custom resource provider. I have deployed this managed application using the service catalog from within the subscription and it works. However, when I publish the managed application to the Azure Marketplace and submit, it requires a swagger definition to be hosted and linkable through a github raw URI.

My swagger definition in json format:

    {
    "swagger": "2.0",
    "info": {
        "title": "Azure Functions Open API Extension",
        "version": "2018-09-01-preview"
    },
    "host": "management.azure.com",
    "schemes": [
        "https"
    ],
    "security": [
        {}
    ],
    "securityDefinitions": {},    
    "paths": {
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{minirpname}/TransitionAccount": {
            "post": {
                "tags": [
                    "PostTransitionAccount"
                ],
                "operationId": "PostTransitionAccount",
                "produces": [
                    "application/json"
                ],
                "parameters": [
                    {
                        "in": "query",
                        "name": "api-version",
                        "description": "api-version is required. Valid versions are 2018-09-01-preview",
                        "required": true,
                        "type": "string"
                    },
                    {
                        "in": "path",
                        "name": "subscriptionId",
                        "description": "This is the Id of the subscription",
                        "required": true,
                        "type": "string"
                    },
                    {
                        "in": "path",
                        "name": "resourceGroupName",
                        "description": "This is the resource group name where the managed app is deployed",
                        "required": true,
                        "type": "string"
                    },
                    {
                        "in": "path",
                        "name": "minirpname",
                        "description": "This is the resource provider name",
                        "required": true,
                        "type": "string"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The OK response",
                        "schema": {}
                    },
                    "500": {
                        "description": "The InternalServerError response",
                        "schema": {}
                    }
                }
            }            
        }
    },
    "parameters": {
        "ApiVersionParameter": {
            "name": "api-version",
            "in": "query",
            "required": true,
            "type": "string",
            "description": "Client Api Version."
        }
    }
}

Marketplace takes and validates this swagger definition upon publishing, however when I deploy the managed app through Marketplace and click the button I get an error.

enter image description here

The error message says "Please check that the swagger validations have a defined route for this operation."

Here is the path definition in my custom resource provider.

{
        "apiVersion": "[variables('customrpApiversion')]",
        "type": "Microsoft.CustomProviders/resourceProviders",
        "name": "[parameters('providerName')]",
        "location": "[parameters('location')]",
        "properties": {
            "actions": [
                {
                    "name": "transitionAccount",
                    "routingType": "Proxy",
                    "endpoint": "[concat('https://', variables('funcname'), '.azurewebsites.net/api/{requestPath}')]"
                }
            ],
            "resourceTypes": [
                {
                    "name": "accountType",
                    "routingType": "Proxy,Cache",
                    "endpoint": "[concat('https://', variables('funcname'), '.azurewebsites.net/api/{requestPath}')]"
                }
            ],
            "Validations" :[
                {
                    "ValidationType": "swagger",
                    "Specification": "https://raw.githubusercontent.com/cleardataeng/azure-shared-image-gallery-syncer/master/metadata/account-type-swagger.json"
                },
                {
                    "ValidationType": "swagger",
                    "Specification": "https://raw.githubusercontent.com/cleardataeng/azure-shared-image-gallery-syncer/master/metadata/transition-account-swagger.json"
                }
            ]
        },
        "dependsOn": [
            "[concat('Microsoft.Web/sites/',variables('funcname'))]"
        ],
        "resources": [
            {
                "type": "accountType",
                "name": "current",
                "apiVersion": "[variables('customrpApiversion')]",
                "location": "[parameters('location')]",
                "properties": {
                    "displayName": "[subscription().displayName]",
                    "tenantId": "[subscription().tenantId]",
                    "subscriptionId": "[subscription().subscriptionId]",
                    "accountType": "Evaluation",
                    "accountTypeStatus": "Pending"
                },
                "dependsOn": [
                    "[concat('Microsoft.CustomProviders/resourceProviders/',parameters('providerName'))]"
                ]
            }
        ]
    }

Why am I receiving an error clicking the Transition Account button in the Marketplace deployed application when I have provided the swagger definition document which was validated during publish?

Edit: The error from activity log is the following. The error extracted from activity log is the following. {"error":{"code":"MissingSwagger","message":"Could not find a valid swagger definition for request '/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/mrg-xxxxxx-managed-appli-20210526184240/providers/Microsoft.CustomProviders/resourceProviders/public/transitionAccount' with method 'POST'. Please check that the swagger validations have a defined route for this operation."}}

Juanma Feliu
  • 1,298
  • 4
  • 16
Rob S.
  • 1,044
  • 7
  • 25
  • recent attempts I have tried modifying "TransitionAccount" to "transitionAccount" in the swaggerfile. I have also attempted combining the swagger docs into a single doc. Neither approach seemed to affect the current issue. – Rob S. May 27 '21 at 15:35

1 Answers1

0

The issue is related to the case sensitive nature of the swagger comparisons. You need to re-create the custom rp after updating the swagger file with the case change. The reason is that we cache the swagger file during the create of the Custom provider resource and will not know an update has happened.

Currently though, we have just completed a deployment that makes swaggers optional for marketplace offers. Please retry your deployments without specifying the validations section and this should start working fine.

suhasrao
  • 73
  • 2
  • i matched the case in the swagger and redeployed the RP with no success. I'm glad the requirement is getting removed, but it would be a nice validation to have if it worked properly – Rob S. Jun 03 '21 at 19:22
  • The validations are still there. It just is not mandatory. We had a bug where it was not actually getting validated for service catalog and have fixed that one as well. Although I am curious. I do not see any calls for "transitionAccount" in the service after 5/27.Are you sure you are getting the same error after the RE-PUT – suhasrao Jun 04 '21 at 21:46
  • I have republished and redeployed the application after making modifications. I would assume this would be equivalent to a RE-PUT. If that is the case then, the answer to your question is "yes". Currently, we have removed the validations from the mainTemplate.json going forward. I am happy to put them back and retest them. Or even get on a call with you directly and show you my experience. – Rob S. Jun 07 '21 at 14:45
  • And yes, the last time I tested transitionAccount was on 5/27. But I had tested after making all the same updates you recommended above (swagger casing changes, recreation of RP, and republish to marketplace). This exact response was recommended via support ticket on 5/25 and attempted on 5/27 after redeploying the application. – Rob S. Jun 07 '21 at 15:02