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

Commit 234d6e0

Browse files
authored
Merge pull request #65 from KetanChawda-MSFT/kechaw-subscriptions-templates
Added subscriptions templates
2 parents 6deeb7c + 0f67b53 commit 234d6e0

9 files changed

+205
-0
lines changed

example/subscriptions/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Subscriptions
2+
3+
This ARM template creates/modfies subscriptions for an existing API Management instance.
4+
5+
**What are subscriptions?**
6+
7+
When you publish APIs through API Management, it's easy and common to secure access to those APIs by using subscription keys. Developers who need to consume the published APIs must include a valid subscription key in HTTP requests when they make calls to those APIs. Otherwise, the calls are rejected immediately by the API Management gateway. They aren't forwarded to the back-end services.
8+
9+
To get a subscription key for accessing APIs, a subscription is required. A subscription is essentially a named container for a pair of subscription keys. Developers who need to consume the published APIs can get subscriptions. And they don't need approval from API publishers. API publishers can also create subscriptions directly for API consumers.
10+
11+
**Instructions:**
12+
13+
1. Clone this repo
14+
2. Using a PowerShell , navigate to the `example/subscriptions` directory
15+
3. Run following Azure PowerShell command to start the process:
16+
17+
```ps
18+
19+
New-AzureRmResourceGroupDeployment -Name 'contoso-deployment' -ResourceGroupName <resource-group> -TemplateFile "subscriptions.*.template.json" -TemplateParameterFile "subscriptions.*.parameters.json"
20+
```
21+
22+
**Note:**
23+
1. Replace `<resource-group>` & parameter values that pertain to your environment in corresponding parameters file.
24+
2. Currently, Subscriptions for all APIs or an individual API is available in the API Management Consumption tier only.
25+
26+
Refer: [Subscriptions in Azure API Management](https://docs.microsoft.com/en-us/azure/api-management/api-management-subscriptions) for more details.
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": "<ApimServiceName>"
7+
},
8+
"SubscriptionName": {
9+
"value": "<subscriptionName>"
10+
}
11+
"ProductName": {
12+
"value": "<ProductName>"
13+
},
14+
"UserName": {
15+
"value": "<UserName>"
16+
}
17+
}
18+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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": "<ApimServiceName>"
7+
},
8+
"SubscriptionName": {
9+
"value": "<subscriptionName>"
10+
},
11+
"APIName": {
12+
"value": "<APIName>"
13+
}
14+
}
15+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
"SubscriptionName": {
9+
"type": "string"
10+
},
11+
"APIName": {
12+
"type": "string"
13+
}
14+
},
15+
"resources": [
16+
{
17+
"type": "Microsoft.ApiManagement/service/subscriptions",
18+
"name": "[concat(parameters('ApimServiceName'), '/', parameters('SubscriptionName'))]",
19+
"apiVersion": "2018-06-01-preview",
20+
"properties": {
21+
"scope": "[resourceId('Microsoft.ApiManagement/service/apis', parameters('ApimServiceName'), parameters('APIName'))]",
22+
"displayName": "[parameters('SubscriptionName')]",
23+
"state": "active",
24+
"allowTracing": true
25+
},
26+
"dependsOn": [
27+
]
28+
}
29+
]
30+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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": "<ApimServiceName>"
7+
},
8+
"SubscriptionName": {
9+
"value": "<subscriptionName>"
10+
}
11+
}
12+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
"SubscriptionName": {
9+
"type": "string"
10+
}
11+
},
12+
"resources": [
13+
{
14+
"type": "Microsoft.ApiManagement/service/subscriptions",
15+
"name": "[concat(parameters('ApimServiceName'), '/', parameters('SubscriptionName'))]",
16+
"apiVersion": "2018-06-01-preview",
17+
"properties": {
18+
"scope": "[concat(resourceId('Microsoft.ApiManagement/service', parameters('ApimServiceName')), '/apis')]",
19+
"displayName": "test",
20+
"state": "active",
21+
"allowTracing": true
22+
},
23+
"dependsOn": [
24+
25+
]
26+
}
27+
]
28+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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": "<ApimServiceName>"
7+
},
8+
"SubscriptionName": {
9+
"value": "<subscriptionName>"
10+
},
11+
"ProductName": {
12+
"value": "<ProductName>"
13+
}
14+
}
15+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
"SubscriptionName": {
9+
"type": "string"
10+
},
11+
"ProductName": {
12+
"type": "string"
13+
}
14+
},
15+
"resources": [
16+
{
17+
"type": "Microsoft.ApiManagement/service/subscriptions",
18+
"name": "[concat(parameters('ApimServiceName'), '/', parameters('SubscriptionName'))]",
19+
"apiVersion": "2018-06-01-preview",
20+
"properties": {
21+
"scope": "[resourceId('Microsoft.ApiManagement/service/products', parameters('ApimServiceName'), parameters('ProductName'))]",
22+
"displayName": "[parameters('SubscriptionName')]",
23+
"state": "active",
24+
"allowTracing": true
25+
},
26+
"dependsOn": [
27+
]
28+
}
29+
]
30+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
"SubscriptionName": {
9+
"type": "string"
10+
},
11+
"ProductName": {
12+
"type": "string"
13+
},
14+
"UserName": {
15+
"type": "string"
16+
}
17+
},
18+
"resources": [
19+
{
20+
"type": "Microsoft.ApiManagement/service/subscriptions",
21+
"name": "[concat(parameters('ApimServiceName'), '/', parameters('SubscriptionName'))]",
22+
"apiVersion": "2018-01-01",
23+
"properties": {
24+
"userId": "[resourceId('Microsoft.ApiManagement/service/users', parameters('ApimServiceName'), parameters('UserName'))]",
25+
"productId": "[resourceId('Microsoft.ApiManagement/service/products', parameters('ApimServiceName'), parameters('ProductName'))]",
26+
"displayName": "Starter product subscription",
27+
"state": "active"
28+
}
29+
}
30+
]
31+
}

0 commit comments

Comments
 (0)