diff --git a/docs/examples/201/api-management-create-all-resources/main.bicep b/docs/examples/201/api-management-create-all-resources/main.bicep new file mode 100644 index 00000000000..862ee2f2b56 --- /dev/null +++ b/docs/examples/201/api-management-create-all-resources/main.bicep @@ -0,0 +1,254 @@ +param publisherEmail string +param publisherName string +param sku string { + default: 'Standard' + allowed: [ + 'Developer' + 'Standard' + 'Premium' + ] +} +param skuCount int = 1 +param mutualAuthenticationCertificate string { + secure: true +} +param certificatePassword string +param eventHubNamespaceConnectionString string +param googleClientSecret string { + secure: true +} +param openIdConnectClientSecret string { + secure: true +} +param tenantPolicy string +param apiPolicy string +param operationPolicy string +param productPolicy string +param location string = resourceGroup().location + +var apiManagementServiceName = 'apiservice${uniqueString(resourceGroup().id)}' + +resource apiManagementService 'Microsoft.ApiManagement/service@2020-06-01-preview' = { + name: apiManagementServiceName + location: location + sku: { + name: sku + capacity: skuCount + } + properties: { + publisherName: publisherName + publisherEmail: publisherEmail + } +} + +resource policy 'Microsoft.ApiManagement/service/policies@2020-06-01-preview' = { + name: '${apiManagementService.name}/policy' + properties: { + value: tenantPolicy + } +} + +resource petStoreApiExample 'Microsoft.ApiManagement/service/apis@2020-06-01-preview' = { + name: '${apiManagementService.name}/PetStoreSwaggerImportExample' + properties: { + format: 'swagger-link-json' + value: 'http://petstore.swagger.io/v2/swagger.json' + path: 'examplepetstore' + } +} + +resource exampleApi 'Microsoft.ApiManagement/service/apis@2020-06-01-preview' = { + name: '${apiManagementService.name}/exampleApi' + properties: { + displayName: 'Example API Name' + description: 'Description for example API' + serviceUrl: 'https://example.net' + path: 'exampleapipath' + protocols: [ + 'https' + ] + } +} + +resource exampleApiOperationDelete 'Microsoft.ApiManagement/service/apis/operations@2020-06-01-preview' = { + name: '${exampleApi.name}/exampleOperationsDELETE' + properties: { + displayName: 'DELETE resource' + method: 'DELETE' + urlTemplate: '/resource' + description: 'A demonstration of a DELETE call' + } +} + +resource exampleApiOperationGet 'Microsoft.ApiManagement/service/apis/operations@2020-06-01-preview' = { + name: '${exampleApi.name}/exampleOperationsGET' + properties: { + displayName: 'GET resource' + method: 'GET' + urlTemplate: '/resource' + description: 'A demonstration of a GET call' + } +} + +resource exampleApiOperationGetPolicy 'Microsoft.ApiManagement/service/apis/operations/policies@2020-06-01-preview' = { + name: '${exampleApiOperationGet.name}/policy' + properties: { + value: operationPolicy + } +} + +resource exampleApiWithPolicy 'Microsoft.ApiManagement/service/apis@2020-06-01-preview' = { + name: '${apiManagementService.name}/exampleApiWithPolicy' + properties: { + displayName: 'Example API Name with policy' + description: 'Description for example API with policy' + serviceUrl: 'https://examplewithpolicy.net' + path: 'exampleapipolicypath' + protocols: [ + 'https' + ] + } +} + +resource exampleApiWithPolicyPolicy 'Microsoft.ApiManagement/service/apis/operations/policies@2020-06-01-preview' = { + name: '${exampleApiWithPolicy.name}/policy' + properties: { + value: apiPolicy + } +} + +resource exampleProduct 'Microsoft.ApiManagement/service/products@2020-06-01-preview' = { + name: '${apiManagementService.name}/exampleProduct' + properties: { + displayName: 'Example Product name' + description: 'Description for example product' + terms: 'Terms for example product' + subscriptionRequired: true + approvalRequired: false + subscriptionsLimit: 1 + state: 'published' + } +} + +resource exampleProductApi 'Microsoft.ApiManagement/service/apis@2020-06-01-preview' = { + name: '${exampleProduct.name}/exampleApi' +} + +resource exampleProductPolicy 'Microsoft.ApiManagement/service/products/policies@2020-06-01-preview' = { + name: '${exampleProduct.name}/policy' + properties: { + value: productPolicy + } +} + +resource exampleUser1 'Microsoft.ApiManagement/service/users@2020-06-01-preview' = { + name: '${apiManagementService.name}/exampleUser1' + properties: { + firstName: 'ExampleFirstName1' + lastName: 'ExampleLastName1' + email: 'examplefirst1@example.com' + state: 'active' + note: 'note for example user 1' + } +} + +resource exampleUser2 'Microsoft.ApiManagement/service/users@2020-06-01-preview' = { + name: '${apiManagementService.name}/exampleUser2' + properties: { + firstName: 'ExampleFirstName2' + lastName: 'ExampleLastName2' + email: 'examplefirst2@example.com' + state: 'active' + note: 'note for example user 2' + } +} + +resource exampleUser3 'Microsoft.ApiManagement/service/users@2020-06-01-preview' = { + name: '${apiManagementService.name}/exampleUser1' + properties: { + firstName: 'ExampleFirstName3' + lastName: 'ExampleLastName3' + email: 'examplefirst3@example.com' + state: 'active' + note: 'note for example user 3' + } +} + +resource exampleProperty 'Microsoft.ApiManagement/service/properties@2019-01-01' = { + name: '${apiManagementService.name}/exampleproperties' + properties: { + displayName: 'propertyExampleName' + value: 'propertyExampleValue' + tags: [ + 'exampleTag' + ] + } +} + +resource subscription1 'Microsoft.ApiManagement/service/subscriptions@2017-03-01' = { + name: '${apiManagementService.name}/examplesubscription1' + properties: { + displayName: 'examplesubscription1' + productId: exampleProduct.id + userId: exampleUser1.id + } +} + +resource subscription2 'Microsoft.ApiManagement/service/subscriptions@2017-03-01' = { + name: '${apiManagementService.name}/examplesubscription2' + properties: { + displayName: 'examplesubscription2' + productId: exampleProduct.id + userId: exampleUser3.id + } +} + +resource certificate 'Microsoft.ApiManagement/service/certificates@2020-06-01-preview' = { + name: '${apiManagementService.name}/exampleCertificate' + properties: { + data: mutualAuthenticationCertificate + password: certificatePassword + } +} + +resource exampleGroup 'Microsoft.ApiManagement/service/groups@2020-06-01-preview' = { + name: '${apiManagementService.name}/exampleGroup' + properties: { + displayName: 'Example Group Name' + description: 'Example group description' + } +} + +resource openIdConnectProvider 'Microsoft.ApiManagement/service/openidConnectProviders@2020-06-01-preview' = { + name: '${apiManagementService.name}/exampleOpenIdConnectProvider' + properties: { + displayName: 'exampleOpenIdConnectProviderName' + description: 'Description for example OpenId Connect provider' + metadataEndpoint: 'https://example-openIdConnect-url.net' + clientId: 'exampleClientId' + clientSecret: openIdConnectClientSecret + } +} + +resource exampleLogger 'Microsoft.ApiManagement/service/loggers@2020-06-01-preview' = { + name: '${apiManagementService.name}/exampleLogger' + properties: { + loggerType: 'azureEventHub' + description: 'Description for example logger' + credentials: { + name: 'exampleEventHubName' + eventHubNamespaceConnectionString: eventHubNamespaceConnectionString + } + } +} + +resource identityProvider 'Microsoft.ApiManagement/service/identityProviders@2020-06-01-preview' = { + name: any('${apiManagementService.name}/google') + properties: { + clientId: 'googleClientId' + clientSecret: googleClientSecret + } + dependsOn: [ + apiManagementService + ] +} diff --git a/docs/examples/201/api-management-create-all-resources/main.json b/docs/examples/201/api-management-create-all-resources/main.json new file mode 100644 index 00000000000..152a8ba2052 --- /dev/null +++ b/docs/examples/201/api-management-create-all-resources/main.json @@ -0,0 +1,377 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "publisherEmail": { + "type": "string" + }, + "publisherName": { + "type": "string" + }, + "sku": { + "type": "string", + "defaultValue": "Standard", + "allowedValues": [ + "Developer", + "Standard", + "Premium" + ] + }, + "skuCount": { + "type": "int", + "defaultValue": 1 + }, + "mutualAuthenticationCertificate": { + "type": "secureString" + }, + "certificatePassword": { + "type": "string" + }, + "eventHubNamespaceConnectionString": { + "type": "string" + }, + "googleClientSecret": { + "type": "secureString" + }, + "openIdConnectClientSecret": { + "type": "secureString" + }, + "tenantPolicy": { + "type": "string" + }, + "apiPolicy": { + "type": "string" + }, + "operationPolicy": { + "type": "string" + }, + "productPolicy": { + "type": "string" + }, + "location": { + "type": "string", + "defaultValue": "[resourceGroup().location]" + } + }, + "functions": [], + "variables": { + "apiManagementServiceName": "[format('apiservice{0}', uniqueString(resourceGroup().id))]" + }, + "resources": [ + { + "type": "Microsoft.ApiManagement/service", + "apiVersion": "2020-06-01-preview", + "name": "[variables('apiManagementServiceName')]", + "location": "[parameters('location')]", + "sku": { + "name": "[parameters('sku')]", + "capacity": "[parameters('skuCount')]" + }, + "properties": { + "publisherName": "[parameters('publisherName')]", + "publisherEmail": "[parameters('publisherEmail')]" + } + }, + { + "type": "Microsoft.ApiManagement/service/policies", + "apiVersion": "2020-06-01-preview", + "name": "[format('{0}/policy', variables('apiManagementServiceName'))]", + "properties": { + "value": "[parameters('tenantPolicy')]" + }, + "dependsOn": [ + "[resourceId('Microsoft.ApiManagement/service', variables('apiManagementServiceName'))]" + ] + }, + { + "type": "Microsoft.ApiManagement/service/apis", + "apiVersion": "2020-06-01-preview", + "name": "[format('{0}/PetStoreSwaggerImportExample', variables('apiManagementServiceName'))]", + "properties": { + "format": "swagger-link-json", + "value": "http://petstore.swagger.io/v2/swagger.json", + "path": "examplepetstore" + }, + "dependsOn": [ + "[resourceId('Microsoft.ApiManagement/service', variables('apiManagementServiceName'))]" + ] + }, + { + "type": "Microsoft.ApiManagement/service/apis", + "apiVersion": "2020-06-01-preview", + "name": "[format('{0}/exampleApi', variables('apiManagementServiceName'))]", + "properties": { + "displayName": "Example API Name", + "description": "Description for example API", + "serviceUrl": "https://example.net", + "path": "exampleapipath", + "protocols": [ + "https" + ] + }, + "dependsOn": [ + "[resourceId('Microsoft.ApiManagement/service', variables('apiManagementServiceName'))]" + ] + }, + { + "type": "Microsoft.ApiManagement/service/apis/operations", + "apiVersion": "2020-06-01-preview", + "name": "[format('{0}/exampleOperationsDELETE', format('{0}/exampleApi', variables('apiManagementServiceName')))]", + "properties": { + "displayName": "DELETE resource", + "method": "DELETE", + "urlTemplate": "/resource", + "description": "A demonstration of a DELETE call" + }, + "dependsOn": [ + "[resourceId('Microsoft.ApiManagement/service/apis', split(format('{0}/exampleApi', variables('apiManagementServiceName')), '/')[0], split(format('{0}/exampleApi', variables('apiManagementServiceName')), '/')[1])]" + ] + }, + { + "type": "Microsoft.ApiManagement/service/apis/operations", + "apiVersion": "2020-06-01-preview", + "name": "[format('{0}/exampleOperationsGET', format('{0}/exampleApi', variables('apiManagementServiceName')))]", + "properties": { + "displayName": "GET resource", + "method": "GET", + "urlTemplate": "/resource", + "description": "A demonstration of a GET call" + }, + "dependsOn": [ + "[resourceId('Microsoft.ApiManagement/service/apis', split(format('{0}/exampleApi', variables('apiManagementServiceName')), '/')[0], split(format('{0}/exampleApi', variables('apiManagementServiceName')), '/')[1])]" + ] + }, + { + "type": "Microsoft.ApiManagement/service/apis/operations/policies", + "apiVersion": "2020-06-01-preview", + "name": "[format('{0}/policy', format('{0}/exampleOperationsGET', format('{0}/exampleApi', variables('apiManagementServiceName'))))]", + "properties": { + "value": "[parameters('operationPolicy')]" + }, + "dependsOn": [ + "[resourceId('Microsoft.ApiManagement/service/apis/operations', split(format('{0}/exampleOperationsGET', format('{0}/exampleApi', variables('apiManagementServiceName'))), '/')[0], split(format('{0}/exampleOperationsGET', format('{0}/exampleApi', variables('apiManagementServiceName'))), '/')[1], split(format('{0}/exampleOperationsGET', format('{0}/exampleApi', variables('apiManagementServiceName'))), '/')[2])]" + ] + }, + { + "type": "Microsoft.ApiManagement/service/apis", + "apiVersion": "2020-06-01-preview", + "name": "[format('{0}/exampleApiWithPolicy', variables('apiManagementServiceName'))]", + "properties": { + "displayName": "Example API Name with policy", + "description": "Description for example API with policy", + "serviceUrl": "https://examplewithpolicy.net", + "path": "exampleapipolicypath", + "protocols": [ + "https" + ] + }, + "dependsOn": [ + "[resourceId('Microsoft.ApiManagement/service', variables('apiManagementServiceName'))]" + ] + }, + { + "type": "Microsoft.ApiManagement/service/apis/operations/policies", + "apiVersion": "2020-06-01-preview", + "name": "[format('{0}/policy', format('{0}/exampleApiWithPolicy', variables('apiManagementServiceName')))]", + "properties": { + "value": "[parameters('apiPolicy')]" + }, + "dependsOn": [ + "[resourceId('Microsoft.ApiManagement/service/apis', split(format('{0}/exampleApiWithPolicy', variables('apiManagementServiceName')), '/')[0], split(format('{0}/exampleApiWithPolicy', variables('apiManagementServiceName')), '/')[1])]" + ] + }, + { + "type": "Microsoft.ApiManagement/service/products", + "apiVersion": "2020-06-01-preview", + "name": "[format('{0}/exampleProduct', variables('apiManagementServiceName'))]", + "properties": { + "displayName": "Example Product name", + "description": "Description for example product", + "terms": "Terms for example product", + "subscriptionRequired": true, + "approvalRequired": false, + "subscriptionsLimit": 1, + "state": "published" + }, + "dependsOn": [ + "[resourceId('Microsoft.ApiManagement/service', variables('apiManagementServiceName'))]" + ] + }, + { + "type": "Microsoft.ApiManagement/service/apis", + "apiVersion": "2020-06-01-preview", + "name": "[format('{0}/exampleApi', format('{0}/exampleProduct', variables('apiManagementServiceName')))]", + "dependsOn": [ + "[resourceId('Microsoft.ApiManagement/service/products', split(format('{0}/exampleProduct', variables('apiManagementServiceName')), '/')[0], split(format('{0}/exampleProduct', variables('apiManagementServiceName')), '/')[1])]" + ] + }, + { + "type": "Microsoft.ApiManagement/service/products/policies", + "apiVersion": "2020-06-01-preview", + "name": "[format('{0}/policy', format('{0}/exampleProduct', variables('apiManagementServiceName')))]", + "properties": { + "value": "[parameters('productPolicy')]" + }, + "dependsOn": [ + "[resourceId('Microsoft.ApiManagement/service/products', split(format('{0}/exampleProduct', variables('apiManagementServiceName')), '/')[0], split(format('{0}/exampleProduct', variables('apiManagementServiceName')), '/')[1])]" + ] + }, + { + "type": "Microsoft.ApiManagement/service/users", + "apiVersion": "2020-06-01-preview", + "name": "[format('{0}/exampleUser1', variables('apiManagementServiceName'))]", + "properties": { + "firstName": "ExampleFirstName1", + "lastName": "ExampleLastName1", + "email": "examplefirst1@example.com", + "state": "active", + "note": "note for example user 1" + }, + "dependsOn": [ + "[resourceId('Microsoft.ApiManagement/service', variables('apiManagementServiceName'))]" + ] + }, + { + "type": "Microsoft.ApiManagement/service/users", + "apiVersion": "2020-06-01-preview", + "name": "[format('{0}/exampleUser2', variables('apiManagementServiceName'))]", + "properties": { + "firstName": "ExampleFirstName2", + "lastName": "ExampleLastName2", + "email": "examplefirst2@example.com", + "state": "active", + "note": "note for example user 2" + }, + "dependsOn": [ + "[resourceId('Microsoft.ApiManagement/service', variables('apiManagementServiceName'))]" + ] + }, + { + "type": "Microsoft.ApiManagement/service/users", + "apiVersion": "2020-06-01-preview", + "name": "[format('{0}/exampleUser1', variables('apiManagementServiceName'))]", + "properties": { + "firstName": "ExampleFirstName3", + "lastName": "ExampleLastName3", + "email": "examplefirst3@example.com", + "state": "active", + "note": "note for example user 3" + }, + "dependsOn": [ + "[resourceId('Microsoft.ApiManagement/service', variables('apiManagementServiceName'))]" + ] + }, + { + "type": "Microsoft.ApiManagement/service/properties", + "apiVersion": "2019-01-01", + "name": "[format('{0}/exampleproperties', variables('apiManagementServiceName'))]", + "properties": { + "displayName": "propertyExampleName", + "value": "propertyExampleValue", + "tags": [ + "exampleTag" + ] + }, + "dependsOn": [ + "[resourceId('Microsoft.ApiManagement/service', variables('apiManagementServiceName'))]" + ] + }, + { + "type": "Microsoft.ApiManagement/service/subscriptions", + "apiVersion": "2017-03-01", + "name": "[format('{0}/examplesubscription1', variables('apiManagementServiceName'))]", + "properties": { + "displayName": "examplesubscription1", + "productId": "[resourceId('Microsoft.ApiManagement/service/products', split(format('{0}/exampleProduct', variables('apiManagementServiceName')), '/')[0], split(format('{0}/exampleProduct', variables('apiManagementServiceName')), '/')[1])]", + "userId": "[resourceId('Microsoft.ApiManagement/service/users', split(format('{0}/exampleUser1', variables('apiManagementServiceName')), '/')[0], split(format('{0}/exampleUser1', variables('apiManagementServiceName')), '/')[1])]" + }, + "dependsOn": [ + "[resourceId('Microsoft.ApiManagement/service', variables('apiManagementServiceName'))]", + "[resourceId('Microsoft.ApiManagement/service/products', split(format('{0}/exampleProduct', variables('apiManagementServiceName')), '/')[0], split(format('{0}/exampleProduct', variables('apiManagementServiceName')), '/')[1])]", + "[resourceId('Microsoft.ApiManagement/service/users', split(format('{0}/exampleUser1', variables('apiManagementServiceName')), '/')[0], split(format('{0}/exampleUser1', variables('apiManagementServiceName')), '/')[1])]" + ] + }, + { + "type": "Microsoft.ApiManagement/service/subscriptions", + "apiVersion": "2017-03-01", + "name": "[format('{0}/examplesubscription2', variables('apiManagementServiceName'))]", + "properties": { + "displayName": "examplesubscription2", + "productId": "[resourceId('Microsoft.ApiManagement/service/products', split(format('{0}/exampleProduct', variables('apiManagementServiceName')), '/')[0], split(format('{0}/exampleProduct', variables('apiManagementServiceName')), '/')[1])]", + "userId": "[resourceId('Microsoft.ApiManagement/service/users', split(format('{0}/exampleUser1', variables('apiManagementServiceName')), '/')[0], split(format('{0}/exampleUser1', variables('apiManagementServiceName')), '/')[1])]" + }, + "dependsOn": [ + "[resourceId('Microsoft.ApiManagement/service', variables('apiManagementServiceName'))]", + "[resourceId('Microsoft.ApiManagement/service/products', split(format('{0}/exampleProduct', variables('apiManagementServiceName')), '/')[0], split(format('{0}/exampleProduct', variables('apiManagementServiceName')), '/')[1])]", + "[resourceId('Microsoft.ApiManagement/service/users', split(format('{0}/exampleUser1', variables('apiManagementServiceName')), '/')[0], split(format('{0}/exampleUser1', variables('apiManagementServiceName')), '/')[1])]" + ] + }, + { + "type": "Microsoft.ApiManagement/service/certificates", + "apiVersion": "2020-06-01-preview", + "name": "[format('{0}/exampleCertificate', variables('apiManagementServiceName'))]", + "properties": { + "data": "[parameters('mutualAuthenticationCertificate')]", + "password": "[parameters('certificatePassword')]" + }, + "dependsOn": [ + "[resourceId('Microsoft.ApiManagement/service', variables('apiManagementServiceName'))]" + ] + }, + { + "type": "Microsoft.ApiManagement/service/groups", + "apiVersion": "2020-06-01-preview", + "name": "[format('{0}/exampleGroup', variables('apiManagementServiceName'))]", + "properties": { + "displayName": "Example Group Name", + "description": "Example group description" + }, + "dependsOn": [ + "[resourceId('Microsoft.ApiManagement/service', variables('apiManagementServiceName'))]" + ] + }, + { + "type": "Microsoft.ApiManagement/service/openidConnectProviders", + "apiVersion": "2020-06-01-preview", + "name": "[format('{0}/exampleOpenIdConnectProvider', variables('apiManagementServiceName'))]", + "properties": { + "displayName": "exampleOpenIdConnectProviderName", + "description": "Description for example OpenId Connect provider", + "metadataEndpoint": "https://example-openIdConnect-url.net", + "clientId": "exampleClientId", + "clientSecret": "[parameters('openIdConnectClientSecret')]" + }, + "dependsOn": [ + "[resourceId('Microsoft.ApiManagement/service', variables('apiManagementServiceName'))]" + ] + }, + { + "type": "Microsoft.ApiManagement/service/loggers", + "apiVersion": "2020-06-01-preview", + "name": "[format('{0}/exampleLogger', variables('apiManagementServiceName'))]", + "properties": { + "loggerType": "azureEventHub", + "description": "Description for example logger", + "credentials": { + "name": "exampleEventHubName", + "eventHubNamespaceConnectionString": "[parameters('eventHubNamespaceConnectionString')]" + } + }, + "dependsOn": [ + "[resourceId('Microsoft.ApiManagement/service', variables('apiManagementServiceName'))]" + ] + }, + { + "type": "Microsoft.ApiManagement/service/identityProviders", + "apiVersion": "2020-06-01-preview", + "name": "[format('{0}/google', variables('apiManagementServiceName'))]", + "properties": { + "clientId": "googleClientId", + "clientSecret": "[parameters('googleClientSecret')]" + }, + "dependsOn": [ + "[resourceId('Microsoft.ApiManagement/service', variables('apiManagementServiceName'))]" + ] + } + ] +} \ No newline at end of file diff --git a/docs/examples/index.json b/docs/examples/index.json index d4551f8c31c..9db272782e7 100644 --- a/docs/examples/index.json +++ b/docs/examples/index.json @@ -247,6 +247,10 @@ "filePath": "201/anchored-proximity-placement-group/main.bicep", "description": "201/anchored-proximity-placement-group" }, + { + "filePath": "201/api-management-create-all-resources/main.bicep", + "description": "201/api-management-create-all-resources" + }, { "filePath": "201/cdn-with-storage-account/main.bicep", "description": "201/cdn-with-storage-account"