Skip to content

Commit 271528d

Browse files
Feature/update input selection process (#93)
1 parent bca6d47 commit 271528d

File tree

10 files changed

+403
-95
lines changed

10 files changed

+403
-95
lines changed

infrastructure/afd-apim-pe/create.ipynb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,7 @@
3737
"# ------------------------------\n",
3838
"\n",
3939
"inb_helper = utils.InfrastructureNotebookHelper(rg_location, INFRASTRUCTURE.AFD_APIM_PE, index, apim_sku) \n",
40-
"success = inb_helper.create_infrastructure()\n",
41-
"\n",
42-
"if not success:\n",
43-
" print(\"❌ Infrastructure creation failed!\")\n",
44-
" raise SystemExit(1)\n",
40+
"inb_helper.create_infrastructure()\n",
4541
"\n",
4642
"utils.print_ok('All done!')"
4743
]

infrastructure/afd-apim-pe/create_infrastructure.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@
1111

1212
def create_infrastructure(location: str, index: int, apim_sku: APIM_SKU, no_aca: bool = False) -> None:
1313
try:
14+
# Check if infrastructure already exists to determine messaging
15+
infrastructure_exists = utils.does_resource_group_exist(utils.get_infra_rg_name(utils.INFRASTRUCTURE.AFD_APIM_PE, index))
16+
1417
# Create custom APIs for AFD-APIM-PE with optional Container Apps backends
1518
custom_apis = _create_afd_specific_apis(not no_aca)
1619

1720
infra = AfdApimAcaInfrastructure(location, index, apim_sku, infra_apis = custom_apis)
18-
result = infra.deploy_infrastructure()
21+
result = infra.deploy_infrastructure(infrastructure_exists)
1922

2023
sys.exit(0 if result.success else 1)
2124

infrastructure/apim-aca/create.ipynb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,7 @@
3535
"# ------------------------------\n",
3636
"\n",
3737
"inb_helper = utils.InfrastructureNotebookHelper(rg_location, INFRASTRUCTURE.APIM_ACA, index, apim_sku) \n",
38-
"success = inb_helper.create_infrastructure()\n",
39-
"\n",
40-
"if not success:\n",
41-
" print(\"❌ Infrastructure creation failed!\")\n",
42-
" raise SystemExit(1)\n",
38+
"inb_helper.create_infrastructure()\n",
4339
"\n",
4440
"utils.print_ok('All done!')"
4541
]

infrastructure/apim-aca/create_infrastructure.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@
1111

1212
def create_infrastructure(location: str, index: int, apim_sku: APIM_SKU) -> None:
1313
try:
14+
# Check if infrastructure already exists to determine messaging
15+
infrastructure_exists = utils.does_resource_group_exist(utils.get_infra_rg_name(utils.INFRASTRUCTURE.APIM_ACA, index))
16+
1417
# Create custom APIs for APIM-ACA with Container Apps backends
1518
custom_apis = _create_aca_specific_apis()
1619

1720
infra = ApimAcaInfrastructure(location, index, apim_sku, infra_apis = custom_apis)
18-
result = infra.deploy_infrastructure()
21+
result = infra.deploy_infrastructure(infrastructure_exists)
1922

2023
sys.exit(0 if result.success else 1)
2124

infrastructure/simple-apim/create.ipynb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,7 @@
3535
"# ------------------------------\n",
3636
"\n",
3737
"inb_helper = utils.InfrastructureNotebookHelper(rg_location, INFRASTRUCTURE.SIMPLE_APIM, index, apim_sku) \n",
38-
"success = inb_helper.create_infrastructure()\n",
39-
"\n",
40-
"if not success:\n",
41-
" print(\"❌ Infrastructure creation failed!\")\n",
42-
" raise SystemExit(1)\n",
38+
"inb_helper.create_infrastructure()\n",
4339
"\n",
4440
"utils.print_ok('All done!')"
4541
]

infrastructure/simple-apim/create_infrastructure.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@
66
import argparse
77
from apimtypes import APIM_SKU
88
from infrastructures import SimpleApimInfrastructure
9+
import utils
910

1011

1112
def create_infrastructure(location: str, index: int, apim_sku: APIM_SKU) -> None:
1213
try:
13-
result = SimpleApimInfrastructure(location, index, apim_sku).deploy_infrastructure()
14+
# Check if infrastructure already exists to determine messaging
15+
infrastructure_exists = utils.does_resource_group_exist(utils.get_infra_rg_name(utils.INFRASTRUCTURE.SIMPLE_APIM, index))
16+
17+
result = SimpleApimInfrastructure(location, index, apim_sku).deploy_infrastructure(infrastructure_exists)
1418
sys.exit(0 if result.success else 1)
1519

1620
except Exception as e:

shared/python/infrastructures.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,17 @@ def _verify_infrastructure_specific(self, rg_name: str) -> bool:
172172
# PUBLIC METHODS
173173
# ------------------------------
174174

175-
def deploy_infrastructure(self) -> 'utils.Output':
175+
def deploy_infrastructure(self, is_update: bool = False) -> 'utils.Output':
176176
"""
177177
Deploy the infrastructure using the defined Bicep parameters.
178178
This method should be implemented in subclasses to handle specific deployment logic.
179+
180+
Args:
181+
is_update (bool): Whether this is an update to existing infrastructure or a new deployment.
179182
"""
180183

181-
print(f'\n🚀 Creating infrastructure...\n')
184+
action_verb = "Updating" if is_update else "Creating"
185+
print(f'\n🚀 {action_verb} infrastructure...\n')
182186
print(f' Infrastructure : {self.infra.value}')
183187
print(f' Index : {self.index}')
184188
print(f' Resource group : {self.rg_name}')
@@ -487,14 +491,18 @@ def _verify_apim_connectivity(self, apim_gateway_url: str) -> bool:
487491
print(' ℹ️ Continuing deployment - this may be expected during infrastructure setup')
488492
return True # Continue anyway
489493

490-
def deploy_infrastructure(self) -> Output:
494+
def deploy_infrastructure(self, is_update: bool = False) -> Output:
491495
"""
492496
Deploy the AFD-APIM-PE infrastructure with the required multi-step process.
493497
498+
Args:
499+
is_update (bool): Whether this is an update to existing infrastructure or a new deployment.
500+
494501
Returns:
495502
utils.Output: The deployment result.
496503
"""
497-
print('\n🚀 Starting AFD-APIM-PE infrastructure deployment...\n')
504+
action_verb = "Updating" if is_update else "Starting"
505+
print(f'\n🚀 {action_verb} AFD-APIM-PE infrastructure deployment...\n')
498506
print(' This deployment requires multiple steps:\n')
499507
print(' 1. Initial deployment with public access enabled')
500508
print(' 2. Approve private link connections')
@@ -503,7 +511,7 @@ def deploy_infrastructure(self) -> Output:
503511
print(' 5. Final verification\n')
504512

505513
# Step 1 & 2: Initial deployment using base class method
506-
output = super().deploy_infrastructure()
514+
output = super().deploy_infrastructure(is_update)
507515

508516
if not output.success:
509517
print('❌ Initial deployment failed!')

0 commit comments

Comments
 (0)