Create an APIM Instance
resource apim 'Microsoft.ApiManagement/service@2021-04-01-preview' = {
name: apimName
location: region
sku: {
name: sku
capacity: 1
}
properties: {
publisherEmail: publisherEmail
publisherName: publisherName
virtualNetworkConfiguration: {
subnetResourceId: '/subscriptions/${subscription().subscriptionId}/resourceGroups/${resourceGroup().name}/providers/Microsoft.Network/virtualNetworks/${virtualNetworkName}/subnets/${subnetName_ApimAccess}'
}
virtualNetworkType:'External'
}
}
This example allows the APIM to be connected to a subnet on a virtual network.
Create a Product
resource adminProduct 'Microsoft.ApiManagement/service/products@2021-04-01-preview' = {
name: '${apim.name}/admin-product'
properties: {
approvalRequired: false
subscriptionRequired: true
displayName: 'Admin product'
state: 'published'
}
}
This one refers the APIM instance created above to get the name and publish instantly.
Create a Subscription
resource adminSubscription 'Microsoft.ApiManagement/service/subscriptions@2021-04-01-preview' = {
name: '${apim.name}/admin-subscription'
properties: {
displayName: 'Admin subscription'
primaryKey: adminSubscription_PrimaryKey
secondaryKey: adminSubscription_SecondaryKey
state: 'active'
scope: '/products/${adminProduct.id}'
}
}
This example refers the product created above as it in intended to scope into the specific product. It also specifies primary key and the secondary key for accessing the APIM.
Create an API
resource configApi 'Microsoft.ApiManagement/service/apis@2021-04-01-preview' = {
name: '${apim.name}/adminApi'
properties: {
displayName: 'Admin API'
description: 'Includes admin operations.'
serviceUrl: '${hostUrl_AdminApp}/config/'
path: 'admin'
protocols: [
'https'
]
}
}
This example creates an API that will redirect the users to a different host url.
No comments:
Post a Comment