Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit d7b5588

Browse files
committed
Merge branch 'lucashh-writeresourcetemplates' into odaibert/extractRules
2 parents 70afd74 + 6448792 commit d7b5588

File tree

63 files changed

+2708
-349
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2708
-349
lines changed

.gitattributes

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
###############################################################################
2+
# Set default behavior to automatically normalize line endings.
3+
###############################################################################
4+
* text=auto
5+
6+
###############################################################################
7+
# Set default behavior for command prompt diff.
8+
#
9+
# This is need for earlier builds of msysgit that does not have it on by
10+
# default for csharp files.
11+
# Note: This is only used by command line
12+
###############################################################################
13+
#*.cs diff=csharp
14+
15+
###############################################################################
16+
# Set the merge driver for project and solution files
17+
#
18+
# Merging from the command prompt will add diff markers to the files if there
19+
# are conflicts (Merging from VS is not affected by the settings below, in VS
20+
# the diff markers are never inserted). Diff markers may cause the following
21+
# file extensions to fail to load in VS. An alternative would be to treat
22+
# these files as binary and thus will always conflict and require user
23+
# intervention with every merge. To do so, just uncomment the entries below
24+
###############################################################################
25+
#*.sln merge=binary
26+
#*.csproj merge=binary
27+
#*.vbproj merge=binary
28+
#*.vcxproj merge=binary
29+
#*.vcproj merge=binary
30+
#*.dbproj merge=binary
31+
#*.fsproj merge=binary
32+
#*.lsproj merge=binary
33+
#*.wixproj merge=binary
34+
#*.modelproj merge=binary
35+
#*.sqlproj merge=binary
36+
#*.wwaproj merge=binary
37+
38+
###############################################################################
39+
# behavior for image files
40+
#
41+
# image files are treated as binary by default.
42+
###############################################################################
43+
#*.jpg binary
44+
#*.png binary
45+
#*.gif binary
46+
47+
###############################################################################
48+
# diff behavior for common document formats
49+
#
50+
# Convert binary document formats to text before diffing them. This feature
51+
# is only available from the command line. Turn it on by uncommenting the
52+
# entries below.
53+
###############################################################################
54+
#*.doc diff=astextplain
55+
#*.DOC diff=astextplain
56+
#*.docx diff=astextplain
57+
#*.DOCX diff=astextplain
58+
#*.dot diff=astextplain
59+
#*.DOT diff=astextplain
60+
#*.pdf diff=astextplain
61+
#*.PDF diff=astextplain
62+
#*.rtf diff=astextplain
63+
#*.RTF diff=astextplain

Example.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Example deployment using the Azure CLI
2+
3+
The following instructions demonstrate how to deploy the contents of this example repository using the [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest).
4+
5+
#### Changing the `ApimServiceName` template parameter
6+
7+
Note that throughout the following steps, the ARM template parameter `ApimServiceName` will need to be unique. If you use the default of `contosoapim-dev` that is used in these templates you will get the following error:
8+
9+
```
10+
Deployment failed. Correlation ID: {
11+
"code": "ServiceAlreadyExists",
12+
"message": "Api service already exists: contosoapim-dev",
13+
"details": null,
14+
"innerError": null
15+
}
16+
```
17+
18+
## Instructions
19+
20+
Login to your Azure subscription:
21+
22+
`az login`
23+
24+
Create a new resource group `apim-rg` that will be used to deploy an APIM instance:
25+
26+
`az group create -n apim-rg -l westeurope`
27+
28+
Deploy the _service template_ to host the APIM _instance_ (note this command can take several minutes to complete):
29+
30+
`az group deployment create --resource-group apim-rg --template-file ./example/service.template.json --parameters ./example/service.parameters.json`
31+
32+
Deploy the `api-httpbin` _API template_ to create an API in the APIM instance:
33+
34+
`az group deployment create --resource-group apim-rg --template-file ./example/api-httpbin/api-httpbin.template.json --parameters ./example/api-httpbin/api-httpbin.parameters.json`
35+
36+
It is of interest the command to create the `api-httpbin` API uses an Open API (swagger) specification `api-httpbin.openapi.json` file when creating the API.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"ApimServiceName": {
6+
"value": "contoso-dev"
7+
},
8+
"ClientID": {
9+
"value": "ClientID"
10+
},
11+
"ClientSecret": {
12+
"value": "<ClentSecret>"
13+
},
14+
"allowedTenants": {
15+
"value": "<tenant>"
16+
}
17+
}
18+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"ApimServiceName": {
6+
"type": "string"
7+
},
8+
"ClientID": {
9+
"type": "string"
10+
},
11+
"ClientSecret": {
12+
"type": "string"
13+
},
14+
"allowedTenants": {
15+
"type": "string"
16+
}
17+
},
18+
"resources": [
19+
{
20+
"type": "Microsoft.ApiManagement/service/identityProviders",
21+
"name": "[concat(parameters('ApimServiceName'), '/aad')]",
22+
"apiVersion": "2018-01-01",
23+
"properties": {
24+
"clientId": "[parameters('ClientID')]",
25+
"clientSecret": "[parameters('ClientSecret')]",
26+
"type": "aad",
27+
"allowedTenants": [
28+
"[parameters('allowedTenants')]"
29+
]
30+
}
31+
}
32+
]
33+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"ApimServiceName": {
6+
"value": "contoso-dev"
7+
},
8+
"ClientID": {
9+
"value": "<ClientID>"
10+
},
11+
"ClientSecret": {
12+
"value": "<ClientSecret>"
13+
},
14+
"IdentityType": {
15+
"value": "facebook"
16+
}
17+
}
18+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"ApimServiceName": {
6+
"type": "string"
7+
},
8+
"ClientID": {
9+
"type": "string"
10+
},
11+
"ClientSecret": {
12+
"type": "string"
13+
},
14+
"IdentityType": {
15+
"type": "string",
16+
"allowedValues": [
17+
"facebook",
18+
"google",
19+
"microsoft",
20+
"twitter"
21+
]
22+
}
23+
},
24+
"resources": [
25+
{
26+
"type": "Microsoft.ApiManagement/service/identityProviders",
27+
"name": "[concat(parameters('ApimServiceName'), '/',parameters('IdentityType'))]",
28+
"apiVersion": "2018-01-01",
29+
"properties": {
30+
"clientId": "[parameters('ClientID')]",
31+
"clientSecret": "[parameters('ClientSecret')]",
32+
"type": "[parameters('IdentityType')]"
33+
}
34+
}
35+
]
36+
}

example/diagnostics/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Integration: Application Insights
2+
3+
This ARM template integrates an existing API Management instance to new Application Insights instance.
4+
5+
**Instructions:**
6+
1. Clone this repo
7+
2. Using a command-line tool, navigate to the `example/diagostics` directory
8+
3. Run following Azure CLI command to start the process:
9+
10+
`az group deployment create --resource-group <resource-group> --template-file ./application-insights.template.json --parameters ApimServiceName=<apim-instance-name> --parameters @application-insights.parameters.json`
11+
12+
Note: be sure to replace `<resource-group>`as well as `<apim-instance-name>` with their corresponding parameters and update the `application-insights.parameters.json` file with appropriate parameters that pertain to your environment.
13+
4. Once completed, your existing API Management instance should be integrated with a newly created Application Insights instance as described in: [How to integrate Azure API Management with Azure Application Insights](https://docs.microsoft.com/en-us/azure/api-management/api-management-howto-app-insights)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema":
3+
"http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
4+
"contentVersion": "1.0.0.0",
5+
"parameters": {
6+
"ApplicationInsightsLocation": {
7+
"value": "westus2"
8+
},
9+
"ApplicationInsightsInstanceName": {
10+
"value": "contoso-appinsights"
11+
},
12+
"SamplingRate": {
13+
"value": 50
14+
}
15+
}
16+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"ApimServiceName": {
6+
"type": "string"
7+
},
8+
"ApplicationInsightsLocation": {
9+
"type": "string"
10+
},
11+
"ApplicationInsightsInstanceName": {
12+
"type": "string"
13+
},
14+
"SamplingRate": {
15+
"type": "int"
16+
}
17+
},
18+
"variables": {},
19+
"resources": [
20+
{
21+
"name": "[parameters('ApplicationInsightsInstanceName')]",
22+
"type": "Microsoft.Insights/components",
23+
"apiVersion": "2015-05-01",
24+
"location": "[parameters('ApplicationInsightsLocation')]",
25+
"tags": {},
26+
"kind": "other",
27+
"properties": {
28+
"Application_Type": "other"
29+
}
30+
},
31+
{
32+
"type": "Microsoft.ApiManagement/service/loggers",
33+
"name": "[concat(parameters('ApimServiceName'), '/', parameters('ApplicationInsightsInstanceName'))]",
34+
"apiVersion": "2018-06-01-preview",
35+
"properties": {
36+
"loggerType": "applicationInsights",
37+
"description": "Logger resources to APIM",
38+
"credentials": {
39+
"instrumentationKey": "[reference(resourceId('Microsoft.Insights/components', parameters('ApplicationInsightsInstanceName')), '2015-05-01').InstrumentationKey]"
40+
}
41+
}
42+
},
43+
{
44+
"type": "Microsoft.ApiManagement/service/diagnostics",
45+
"name": "[concat(parameters('ApimServiceName'), '/applicationinsights')]",
46+
"apiVersion": "2018-06-01-preview",
47+
"properties": {
48+
"alwaysLog": "allErrors",
49+
"loggerId": "[concat('/loggers/', parameters('ApplicationInsightsInstanceName'))]",
50+
"sampling": {
51+
"samplingType": "fixed",
52+
"percentage": "[parameters('SamplingRate')]"
53+
},
54+
"frontend": {
55+
"request": {
56+
"headers": [],
57+
"body": {}
58+
},
59+
"response": {
60+
"headers": [],
61+
"body": {}
62+
}
63+
},
64+
"backend": {
65+
"request": {
66+
"headers": [],
67+
"body": {}
68+
},
69+
"response": {
70+
"headers": [],
71+
"body": {}
72+
}
73+
},
74+
"enableHttpCorrelationHeaders": false
75+
},
76+
"dependsOn": [
77+
"[resourceId('Microsoft.ApiManagement/service/loggers', parameters('ApimServiceName'), parameters('ApplicationInsightsInstanceName'))]"
78+
]
79+
}
80+
81+
]
82+
}

example/full-file.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"value": [
3+
{
4+
"id": "/subscriptions/cabe3525-a754-4bf7-9af4-1a9746604527/resourceGroups/APIM-Extractor/providers/Microsoft.ApiManagement/service/apim-extractor/apis/httpBinAPI",
5+
"type": "Microsoft.ApiManagement/service",
6+
"name": "httpBinAPI",
7+
"properties": {
8+
"displayName": "HTTP Bin API",
9+
"apiRevision": "1",
10+
"description": "API Management facade for a very handy and free online HTTP tool",
11+
"serviceUrl": "https://httpbin.org",
12+
"path": "httpbin",
13+
"protocols": [
14+
"https"
15+
],
16+
"authenticationSettings": null,
17+
"subscriptionKeyParameterNames": null,
18+
"isCurrent": true,
19+
"apiVersion": "v1",
20+
"apiVersionSetId": "/subscriptions/cabe3525-a754-4bf7-9af4-1a9746604527/resourceGroups/APIM-Extractor/providers/Microsoft.ApiManagement/service/apim-extractor/api-version-sets/versionset-httpbin-api"
21+
}
22+
}
23+
]
24+
}
25+
httpBinAPI
26+
{
27+
"id": "/subscriptions/cabe3525-a754-4bf7-9af4-1a9746604527/resourceGroups/APIM-Extractor/providers/Microsoft.ApiManagement/service/apim-extractor/apis/httpBinAPI",
28+
"type": "Microsoft.ApiManagement/service/apis",
29+
"name": "httpBinAPI",
30+
"properties": {
31+
"displayName": "HTTP Bin API",
32+
"apiRevision": "1",
33+
"description": "API Management facade for a very handy and free online HTTP tool",
34+
"serviceUrl": "https://httpbin.org",
35+
"path": "httpbin",
36+
"protocols": [
37+
"https"
38+
],
39+
"authenticationSettings": {
40+
"oAuth2": null,
41+
"openid": null
42+
},
43+
"subscriptionKeyParameterNames": {
44+
"header": "Ocp-Apim-Subscription-Key",
45+
"query": "subscription-key"
46+
},
47+
"isCurrent": true,
48+
"apiVersion": "v1",
49+
"apiVersionSetId": "/subscriptions/cabe3525-a754-4bf7-9af4-1a9746604527/resourceGroups/APIM-Extractor/providers/Microsoft.ApiManagement/service/apim-extractor/api-version-sets/versionset-httpbin-api"
50+
}
51+
}

0 commit comments

Comments
 (0)