1+ {
2+ "$schema" : " https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#" ,
3+ "contentVersion" : " 1.0.0.0" ,
4+ "metadata" : {
5+ "_generator" : {
6+ "name" : " bicep" ,
7+ "version" : " 0.38.33.27573" ,
8+ "templateHash" : " 16240781146342215937"
9+ }
10+ },
11+ "parameters" : {
12+ "apimInstanceName" : {
13+ "type" : " string"
14+ },
15+ "oaiApiName" : {
16+ "type" : " string"
17+ },
18+ "openAiServiceUrl" : {
19+ "type" : " string"
20+ },
21+ "enableJwt" : {
22+ "type" : " bool" ,
23+ "defaultValue" : true ,
24+ "metadata" : {
25+ "description" : " Deploy the JWT-authenticated OpenAI API endpoint."
26+ }
27+ },
28+ "enableKeys" : {
29+ "type" : " bool" ,
30+ "defaultValue" : true ,
31+ "metadata" : {
32+ "description" : " Deploy the subscription-key-authenticated OpenAI API endpoint."
33+ }
34+ }
35+ },
36+ "variables" : {
37+ "passthroughMethods" : [
38+ " GET" ,
39+ " POST" ,
40+ " PUT" ,
41+ " PATCH" ,
42+ " DELETE" ,
43+ " HEAD" ,
44+ " OPTIONS"
45+ ]
46+ },
47+ "resources" : [
48+ {
49+ "type" : " Microsoft.ApiManagement/service/backends" ,
50+ "apiVersion" : " 2021-08-01" ,
51+ "name" : " [format('{0}/{1}', parameters('apimInstanceName'), 'openAiBackend')]" ,
52+ "properties" : {
53+ "url" : " [parameters('openAiServiceUrl')]" ,
54+ "protocol" : " http" ,
55+ "title" : " OpenAI Backend" ,
56+ "description" : " Backend for Azure OpenAI APIs"
57+ }
58+ },
59+ {
60+ "condition" : " [parameters('enableJwt')]" ,
61+ "type" : " Microsoft.ApiManagement/service/apis" ,
62+ "apiVersion" : " 2021-08-01" ,
63+ "name" : " [format('{0}/{1}', parameters('apimInstanceName'), format('{0}-jwt', parameters('oaiApiName')))]" ,
64+ "properties" : {
65+ "displayName" : " Azure OpenAI Service API" ,
66+ "path" : " jwt/openai" ,
67+ "serviceUrl" : " [parameters('openAiServiceUrl')]" ,
68+ "protocols" : [
69+ " https"
70+ ],
71+ "subscriptionRequired" : false
72+ }
73+ },
74+ {
75+ "copy" : {
76+ "name" : " apimJwtOaiApiPassthrough" ,
77+ "count" : " [length(if(parameters('enableJwt'), variables('passthroughMethods'), createArray()))]" ,
78+ "mode" : " serial" ,
79+ "batchSize" : 1
80+ },
81+ "type" : " Microsoft.ApiManagement/service/apis/operations" ,
82+ "apiVersion" : " 2021-08-01" ,
83+ "name" : " [format('{0}/{1}/{2}', parameters('apimInstanceName'), format('{0}-jwt', parameters('oaiApiName')), format('passthrough-{0}', toLower(if(parameters('enableJwt'), variables('passthroughMethods'), createArray())[copyIndex()])))]" ,
84+ "properties" : {
85+ "displayName" : " [format('Passthrough {0}', if(parameters('enableJwt'), variables('passthroughMethods'), createArray())[copyIndex()])]" ,
86+ "method" : " [if(parameters('enableJwt'), variables('passthroughMethods'), createArray())[copyIndex()]]" ,
87+ "urlTemplate" : " /*"
88+ },
89+ "dependsOn" : [
90+ " [resourceId('Microsoft.ApiManagement/service/apis', parameters('apimInstanceName'), format('{0}-jwt', parameters('oaiApiName')))]"
91+ ]
92+ },
93+ {
94+ "condition" : " [parameters('enableKeys')]" ,
95+ "type" : " Microsoft.ApiManagement/service/apis" ,
96+ "apiVersion" : " 2021-08-01" ,
97+ "name" : " [format('{0}/{1}', parameters('apimInstanceName'), format('{0}-keys', parameters('oaiApiName')))]" ,
98+ "properties" : {
99+ "displayName" : " Azure OpenAI Key-Based API" ,
100+ "path" : " keys/openai" ,
101+ "serviceUrl" : " [parameters('openAiServiceUrl')]" ,
102+ "protocols" : [
103+ " https"
104+ ],
105+ "subscriptionRequired" : true
106+ }
107+ },
108+ {
109+ "copy" : {
110+ "name" : " apimKeyOaiApiPassthrough" ,
111+ "count" : " [length(if(parameters('enableKeys'), variables('passthroughMethods'), createArray()))]" ,
112+ "mode" : " serial" ,
113+ "batchSize" : 1
114+ },
115+ "type" : " Microsoft.ApiManagement/service/apis/operations" ,
116+ "apiVersion" : " 2021-08-01" ,
117+ "name" : " [format('{0}/{1}/{2}', parameters('apimInstanceName'), format('{0}-keys', parameters('oaiApiName')), format('key-passthrough-{0}', toLower(if(parameters('enableKeys'), variables('passthroughMethods'), createArray())[copyIndex()])))]" ,
118+ "properties" : {
119+ "displayName" : " [format('Key Passthrough {0}', if(parameters('enableKeys'), variables('passthroughMethods'), createArray())[copyIndex()])]" ,
120+ "method" : " [if(parameters('enableKeys'), variables('passthroughMethods'), createArray())[copyIndex()]]" ,
121+ "urlTemplate" : " /*"
122+ },
123+ "dependsOn" : [
124+ " [resourceId('Microsoft.ApiManagement/service/apis', parameters('apimInstanceName'), format('{0}-keys', parameters('oaiApiName')))]"
125+ ]
126+ }
127+ ]
128+ }
0 commit comments