Skip to content

Commit 8eac79b

Browse files
Clean up (#25)
1 parent 17e21f9 commit 8eac79b

File tree

23 files changed

+104
-138
lines changed

23 files changed

+104
-138
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ labs-in-progress/
2727
.coverage
2828
tests/python/htmlcov/
2929

30-
shared/bicep/modules/**/*.json
30+
shared/bicep/modules/**/*.json
31+
main.json

infrastructure/afd-apim/create.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@
5757
"if use_ACA:\n",
5858
" utils.print_info('ACA APIs will be created.')\n",
5959
"\n",
60-
" aca_backend_1_policy_xml = utils.read_policy_xml(ACA_BACKEND_1_XML_POLICY_PATH)\n",
61-
" aca_backend_2_policy_xml = utils.read_policy_xml(ACA_BACKEND_2_XML_POLICY_PATH)\n",
62-
" aca_backend_pool_policy_xml = utils.read_policy_xml(ACA_BACKEND_POOL_XML_POLICY_PATH)\n",
60+
" aca_backend_1_policy_xml = utils.read_policy_xml(BACKEND_XML_POLICY_PATH).format(backend_id = 'aca-backend-1')\n",
61+
" aca_backend_2_policy_xml = utils.read_policy_xml(BACKEND_XML_POLICY_PATH).format(backend_id = 'aca-backend-2')\n",
62+
" aca_backend_pool_policy_xml = utils.read_policy_xml(BACKEND_XML_POLICY_PATH).format(backend_id = 'aca-backend-pool')\n",
6363
"\n",
6464
" # Hello World (ACA Backend 1)\n",
6565
" api_hwaca_1_get = GET_APIOperation('This is a GET for Hello World on ACA Backend 1')\n",

infrastructure/afd-apim/main.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ module backendPoolModule '../../shared/bicep/modules/apim/v1/backend-pool.bicep'
226226

227227
// 8. APIM APIs
228228
module apisModule '../../shared/bicep/modules/apim/v1/api.bicep' = [for api in apis: if(length(apis) > 0) {
229-
name: '${api.name}-${resourceSuffix}'
229+
name: 'api-${api.name}'
230230
params: {
231231
apimName: apimName
232232
appInsightsInstrumentationKey: appInsightsInstrumentationKey

infrastructure/apim-aca/create.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646
"\n",
4747
"# Policies\n",
4848
"hello_world_policy_xml = utils.read_policy_xml(HELLO_WORLD_XML_POLICY_PATH)\n",
49-
"aca_backend_1_policy_xml = utils.read_policy_xml(ACA_BACKEND_1_XML_POLICY_PATH)\n",
50-
"aca_backend_2_policy_xml = utils.read_policy_xml(ACA_BACKEND_2_XML_POLICY_PATH)\n",
51-
"aca_backend_pool_policy_xml = utils.read_policy_xml(ACA_BACKEND_POOL_XML_POLICY_PATH)\n",
49+
"aca_backend_1_policy_xml = utils.read_policy_xml(BACKEND_XML_POLICY_PATH).format(backend_id = 'aca-backend-1')\n",
50+
"aca_backend_2_policy_xml = utils.read_policy_xml(BACKEND_XML_POLICY_PATH).format(backend_id = 'aca-backend-2')\n",
51+
"aca_backend_pool_policy_xml = utils.read_policy_xml(BACKEND_XML_POLICY_PATH).format(backend_id = 'aca-backend-pool')\n",
5252
"\n",
5353
"# Hello World (Root)\n",
5454
"api_hwroot_get = GET_APIOperation('This is a GET for Hello World in the root', hello_world_policy_xml)\n",

infrastructure/apim-aca/main.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ module backendPoolModule '../../shared/bicep/modules/apim/v1/backend-pool.bicep'
134134
// 7. APIM APIs
135135
module apisModule '../../shared/bicep/modules/apim/v1/api.bicep' = [
136136
for api in apis: if (length(apis) > 0) {
137-
name: '${api.name}-${resourceSuffix}'
137+
name: 'api-${api.name}'
138138
params: {
139139
apimName: apimName
140140
appInsightsInstrumentationKey: appInsightsInstrumentationKey

infrastructure/simple-apim/main.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ module apimModule '../../shared/bicep/modules/apim/v1/apim.bicep' = {
4949

5050
// 4. APIM APIs
5151
module apisModule '../../shared/bicep/modules/apim/v1/api.bicep' = [for api in apis: if(length(apis) > 0) {
52-
name: '${api.name}-${resourceSuffix}'
52+
name: 'api-${api.name}'
5353
params: {
5454
apimName: apimName
5555
appInsightsInstrumentationKey: appInsightsInstrumentationKey

samples/authX-pro/create.ipynb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,9 @@
126126
" hr_member_role_id = '{{HRMemberRoleId}}'\n",
127127
")\n",
128128
"\n",
129+
"hr_product_name = 'hr'\n",
129130
"products: List[Product] = [\n",
130-
" Product('hr', 'Human Resources', 'Product for Human Resources APIs providing access to employee data, organizational structure, benefits information, and HR management services. Includes JWT-based authentication for HR members.', 'published', False, False, hr_product_xml)\n",
131+
" Product(hr_product_name, 'Human Resources', 'Product for Human Resources APIs providing access to employee data, organizational structure, benefits information, and HR management services. Includes JWT-based authentication for HR members.', 'published', False, False, hr_product_xml)\n",
131132
"]\n",
132133
"\n",
133134
"# 6) Define the APIs and their operations and policies\n",
@@ -136,13 +137,13 @@
136137
"hremployees_api_path = f'/{api_prefix}employees'\n",
137138
"hremployees_get = GET_APIOperation('Gets the employees', utils.read_policy_xml('./hr_get.xml'))\n",
138139
"hremployees_post = POST_APIOperation('Creates a new employee', utils.read_policy_xml('./hr_post.xml'))\n",
139-
"hremployees = API(f'{api_prefix}Employees', 'Employees Pro', hremployees_api_path, 'This is a Human Resources API for employee information', utils.read_policy_xml(DEFAULT_XML_POLICY_PATH), operations = [hremployees_get, hremployees_post], tags = tags, productNames = ['hr'])\n",
140+
"hremployees = API(f'{api_prefix}Employees', 'Employees Pro', hremployees_api_path, 'This is a Human Resources API for employee information', utils.read_policy_xml(DEFAULT_XML_POLICY_PATH), operations = [hremployees_get, hremployees_post], tags = tags, productNames = [hr_product_name])\n",
140141
"\n",
141142
"# Benefits (HR)\n",
142143
"hrbenefits_api_path = f'/{api_prefix}benefits'\n",
143144
"hrbenefits_get = GET_APIOperation('Gets employee benefits', utils.read_policy_xml('./hr_get.xml'))\n",
144145
"hrbenefits_post = POST_APIOperation('Creates employee benefits', utils.read_policy_xml('./hr_post.xml'))\n",
145-
"hrbenefits = API(f'{api_prefix}Benefits', 'Benefits Pro', hrbenefits_api_path, 'This is a Human Resources API for employee benefits', utils.read_policy_xml(DEFAULT_XML_POLICY_PATH), operations = [hrbenefits_get, hrbenefits_post], tags = tags, productNames = ['hr'])\n",
146+
"hrbenefits = API(f'{api_prefix}Benefits', 'Benefits Pro', hrbenefits_api_path, 'This is a Human Resources API for employee benefits', utils.read_policy_xml(DEFAULT_XML_POLICY_PATH), operations = [hrbenefits_get, hrbenefits_post], tags = tags, productNames = [hr_product_name])\n",
146147
"\n",
147148
"# APIs Array\n",
148149
"apis: List[API] = [hremployees, hrbenefits]\n",
@@ -171,7 +172,8 @@
171172
"bicep_parameters = {\n",
172173
" 'apis': {'value': [api.to_dict() for api in apis]},\n",
173174
" 'namedValues': {'value': [nv.to_dict() for nv in nvs]},\n",
174-
" 'policyFragments': {'value': [pf.to_dict() for pf in pfs]}\n",
175+
" 'policyFragments': {'value': [pf.to_dict() for pf in pfs]},\n",
176+
" 'products': {'value': [product.to_dict() for product in products]}\n",
175177
"}\n",
176178
"\n",
177179
"# 2) Infrastructure must be in place before samples can be layered on top\n",

samples/authX-pro/main.bicep

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ module productHr '../../shared/bicep/modules/apim/v1/product.bicep' = [for produ
7878
]
7979
}]
8080

81-
// APIM APIs
81+
// APIM APIs (deployed after products are ready to avoid race conditions)
82+
@batchSize(1) // Deploy APIs sequentially to avoid race conditions
8283
module apisModule '../../shared/bicep/modules/apim/v1/api.bicep' = [for api in apis: {
8384
name: 'api-${api.name}'
8485
params:{
@@ -90,7 +91,8 @@ module apisModule '../../shared/bicep/modules/apim/v1/api.bicep' = [for api in a
9091
}
9192
dependsOn: [
9293
namedValue // ensure all named values are created before APIs
93-
productHr // ensure products are created before APIs that reference them
94+
policyFragment // ensure all policy fragments are created before APIs
95+
productHr // ensure all products are fully created before APIs
9496
]
9597
}]
9698

samples/authX/hr_product.xml

Lines changed: 0 additions & 31 deletions
This file was deleted.

samples/authX/main.bicep

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ resource apimService 'Microsoft.ApiManagement/service@2024-06-01-preview' existi
3434

3535
// APIM Named Values
3636
module namedValue '../../shared/bicep/modules/apim/v1/named-value.bicep' = [for nv in namedValues: if (!empty(namedValues)) {
37-
name: nv.name
37+
name: 'nv-${nv.name}'
3838
params: {
3939
apimName: apimName
4040
namedValueName: nv.name
@@ -45,7 +45,7 @@ module namedValue '../../shared/bicep/modules/apim/v1/named-value.bicep' = [for
4545

4646
// APIM APIs
4747
module apisModule '../../shared/bicep/modules/apim/v1/api.bicep' = [for api in apis: if(!empty(apis)) {
48-
name: '${api.name}-${resourceSuffix}'
48+
name: 'api-${api.name}'
4949
params: {
5050
apimName: apimName
5151
appInsightsInstrumentationKey: appInsightsInstrumentationKey

0 commit comments

Comments
 (0)