Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions infrastructure/afd-apim-pe/create.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@
"# ------------------------------\n",
"\n",
"inb_helper = utils.InfrastructureNotebookHelper(rg_location, INFRASTRUCTURE.AFD_APIM_PE, index, apim_sku) \n",
"success = inb_helper.create_infrastructure()\n",
"\n",
"if not success:\n",
" print(\"❌ Infrastructure creation failed!\")\n",
" raise SystemExit(1)\n",
"inb_helper.create_infrastructure()\n",
"\n",
"utils.print_ok('All done!')"
]
Expand Down
5 changes: 4 additions & 1 deletion infrastructure/afd-apim-pe/create_infrastructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@

def create_infrastructure(location: str, index: int, apim_sku: APIM_SKU, no_aca: bool = False) -> None:
try:
# Check if infrastructure already exists to determine messaging
infrastructure_exists = utils.does_resource_group_exist(utils.get_infra_rg_name(utils.INFRASTRUCTURE.AFD_APIM_PE, index))

# Create custom APIs for AFD-APIM-PE with optional Container Apps backends
custom_apis = _create_afd_specific_apis(not no_aca)

infra = AfdApimAcaInfrastructure(location, index, apim_sku, infra_apis = custom_apis)
result = infra.deploy_infrastructure()
result = infra.deploy_infrastructure(infrastructure_exists)

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

Expand Down
6 changes: 1 addition & 5 deletions infrastructure/apim-aca/create.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@
"# ------------------------------\n",
"\n",
"inb_helper = utils.InfrastructureNotebookHelper(rg_location, INFRASTRUCTURE.APIM_ACA, index, apim_sku) \n",
"success = inb_helper.create_infrastructure()\n",
"\n",
"if not success:\n",
" print(\"❌ Infrastructure creation failed!\")\n",
" raise SystemExit(1)\n",
"inb_helper.create_infrastructure()\n",
"\n",
"utils.print_ok('All done!')"
]
Expand Down
5 changes: 4 additions & 1 deletion infrastructure/apim-aca/create_infrastructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@

def create_infrastructure(location: str, index: int, apim_sku: APIM_SKU) -> None:
try:
# Check if infrastructure already exists to determine messaging
infrastructure_exists = utils.does_resource_group_exist(utils.get_infra_rg_name(utils.INFRASTRUCTURE.APIM_ACA, index))

# Create custom APIs for APIM-ACA with Container Apps backends
custom_apis = _create_aca_specific_apis()

infra = ApimAcaInfrastructure(location, index, apim_sku, infra_apis = custom_apis)
result = infra.deploy_infrastructure()
result = infra.deploy_infrastructure(infrastructure_exists)

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

Expand Down
6 changes: 1 addition & 5 deletions infrastructure/simple-apim/create.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@
"# ------------------------------\n",
"\n",
"inb_helper = utils.InfrastructureNotebookHelper(rg_location, INFRASTRUCTURE.SIMPLE_APIM, index, apim_sku) \n",
"success = inb_helper.create_infrastructure()\n",
"\n",
"if not success:\n",
" print(\"❌ Infrastructure creation failed!\")\n",
" raise SystemExit(1)\n",
"inb_helper.create_infrastructure()\n",
"\n",
"utils.print_ok('All done!')"
]
Expand Down
6 changes: 5 additions & 1 deletion infrastructure/simple-apim/create_infrastructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@
import argparse
from apimtypes import APIM_SKU
from infrastructures import SimpleApimInfrastructure
import utils


def create_infrastructure(location: str, index: int, apim_sku: APIM_SKU) -> None:
try:
result = SimpleApimInfrastructure(location, index, apim_sku).deploy_infrastructure()
# Check if infrastructure already exists to determine messaging
infrastructure_exists = utils.does_resource_group_exist(utils.get_infra_rg_name(utils.INFRASTRUCTURE.SIMPLE_APIM, index))

result = SimpleApimInfrastructure(location, index, apim_sku).deploy_infrastructure(infrastructure_exists)
sys.exit(0 if result.success else 1)

except Exception as e:
Expand Down
18 changes: 13 additions & 5 deletions shared/python/infrastructures.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,17 @@ def _verify_infrastructure_specific(self, rg_name: str) -> bool:
# PUBLIC METHODS
# ------------------------------

def deploy_infrastructure(self) -> 'utils.Output':
def deploy_infrastructure(self, is_update: bool = False) -> 'utils.Output':
"""
Deploy the infrastructure using the defined Bicep parameters.
This method should be implemented in subclasses to handle specific deployment logic.

Args:
is_update (bool): Whether this is an update to existing infrastructure or a new deployment.
"""

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

def deploy_infrastructure(self) -> Output:
def deploy_infrastructure(self, is_update: bool = False) -> Output:
"""
Deploy the AFD-APIM-PE infrastructure with the required multi-step process.

Args:
is_update (bool): Whether this is an update to existing infrastructure or a new deployment.

Returns:
utils.Output: The deployment result.
"""
print('\n🚀 Starting AFD-APIM-PE infrastructure deployment...\n')
action_verb = "Updating" if is_update else "Starting"
print(f'\n🚀 {action_verb} AFD-APIM-PE infrastructure deployment...\n')
print(' This deployment requires multiple steps:\n')
print(' 1. Initial deployment with public access enabled')
print(' 2. Approve private link connections')
Expand All @@ -503,7 +511,7 @@ def deploy_infrastructure(self) -> Output:
print(' 5. Final verification\n')

# Step 1 & 2: Initial deployment using base class method
output = super().deploy_infrastructure()
output = super().deploy_infrastructure(is_update)

if not output.success:
print('❌ Initial deployment failed!')
Expand Down
Loading
Loading