I have an ARM template to deploy a custom connector (or an update) on the Azure pipeline,
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
...
"swaggerSpec": {
"type": "string",
"defaultValue": "http://someapi/v1/swagger/docs/v1"
}
...
},
"resources": [
{
"type": "Microsoft.Web/customApis",
"apiVersion": "2016-06-01",
"name": "[parameters('connectorName')]",
"location": "[parameters('location')]",
"properties": {
...
"apiType": "rest",
"apiDefinitions": {
"originalSwaggerUrl": "[parameters('swaggerSpec')]"
}
...
},
...
}
]
}
This can be deployed successfully(with no errors), but the API definition is not updated to the latest. Not sure what happened or is it correct that I'm using originalSwaggerUrl
?
Cheers
Looking at the documentation, you could use the swagger
property:
Name: swagger
Description: The JSON representation of the swagger
Value: For Bicep, you can use the any() function.
If you have access to the swagger file locally, you have few options
Pass the json definition as an object parameter:
param connectorName string
param location string
param swagger object
resource customApi 'Microsoft.Web/customApis@2016-06-01' = {
name: connectorName
location: location
properties: {
...
apiType: 'apiType'
swagger: swagger
...
}
}
Then you can deploy your template like that (using az cli and powershell here):
$swaggerPath="full/path/of/the/swagger/file.json"
az deployment group create `
--resource-group "resource group name" `
--template-file "full/path/of/the/main.bicep" `
--parameters connectorName="connector name" `
--parameters location="resource location" `
--parameters swagger=@$swaggerPath
Use the Bicep loadJsonContent
The maximum allowed size of the file is 1,048,576 characters, including line endings.
param connectorName string
param location string
var swagger = loadJsonContent('path/to/swagger/file/')
resource customApi 'Microsoft.Web/customApis@2016-06-01' = {
name: connectorName
location: location
properties: {
...
apiType: 'apiType'
swagger: swagger
...
}
}