diff --git a/azure.yaml b/azure.yaml index 65c29aff..0a74a2d6 100644 --- a/azure.yaml +++ b/azure.yaml @@ -36,15 +36,6 @@ hooks: run: ./scripts/setup_postgres_database.sh;./scripts/setup_postgres_azurerole.sh;./scripts/setup_postgres_seeddata.sh interactive: true continueOnError: false - predown: - windows: - shell: pwsh - run: ./scripts/pre_down.ps1 - continueOnError: true - posix: - shell: sh - run: ./scripts/pre_down.sh - continueOnError: true pipeline: variables: - DEPLOY_AZURE_OPENAI diff --git a/scripts/pre_down.ps1 b/scripts/pre_down.ps1 deleted file mode 100644 index 63a0604f..00000000 --- a/scripts/pre_down.ps1 +++ /dev/null @@ -1,5 +0,0 @@ -# Get the directory of the current script -$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition - -# Run the Python script -python "$scriptDir/pre-down.py" diff --git a/scripts/pre_down.py b/scripts/pre_down.py deleted file mode 100644 index 7080e539..00000000 --- a/scripts/pre_down.py +++ /dev/null @@ -1,54 +0,0 @@ -import logging -import os - -from azure.identity import AzureDeveloperCliCredential -from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient -from dotenv_azd import load_azd_env - -logger = logging.getLogger("ragapp") - - -def delete_deployments(resource_name: str, resource_group: str, subscription_id: str, tenant_id: str | None = None): - """ - Delete all deployments for an Azure OpenAI resource - """ - if tenant_id: - logger.info("Authenticating to Azure using Azure Developer CLI Credential for tenant %s", tenant_id) - azure_credential = AzureDeveloperCliCredential(tenant_id=tenant_id, process_timeout=60) - else: - logger.info("Authenticating to Azure using Azure Developer CLI Credential") - azure_credential = AzureDeveloperCliCredential(process_timeout=60) - - # Initialize the Cognitive Services client - client = CognitiveServicesManagementClient(azure_credential, subscription_id=subscription_id) - - # List all deployments - deployments = client.deployments.list(resource_group_name=resource_group, account_name=resource_name) - - # Delete each deployment and wait for the operation to complete - for deployment in deployments: - deployment_name = deployment.name - if not deployment_name: - continue - poller = client.deployments.begin_delete( - resource_group_name=resource_group, account_name=resource_name, deployment_name=deployment_name - ) - poller.result() - logger.info(f"Deployment {deployment_name} deleted successfully.") - - -if __name__ == "__main__": - logging.basicConfig(level=logging.WARNING) - logger.setLevel(logging.INFO) - load_azd_env() - - try: - resource_name = os.environ["AZURE_OPENAI_SERVICE"] - resource_group = os.environ["AZURE_OPENAI_RESOURCE_GROUP"] - subscription_id = os.environ["AZURE_SUBSCRIPTION_ID"] - tenant_id = os.environ["AZURE_TENANT_ID"] - except KeyError as e: - logger.error("Missing azd environment variable %s", e) - exit(1) - - delete_deployments(resource_name, resource_group, subscription_id, tenant_id) diff --git a/scripts/pre_down.sh b/scripts/pre_down.sh deleted file mode 100755 index 8679e863..00000000 --- a/scripts/pre_down.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -. ./scripts/load_python_env.sh - -# Get the directory of the current script -script_dir=$(dirname "$0") - -# Run the Python script with the retrieved values -.venv/bin/python "$script_dir/pre_down.py" --subscription-id $subscription_id --resource-name $resource_name --resource-group $resource_group --tenant-id $tenant_id