Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add scripts to deploy to azure
  • Loading branch information
yiliuTo committed Mar 19, 2025
commit fc625b08919637d4bfaee0229c927a02e08b7731
67 changes: 67 additions & 0 deletions asset-manager/scripts/cleanup-azure-resources.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
@echo off
setlocal enabledelayedexpansion

rem Azure Resources Cleanup Script for Assets Manager
rem Execute with: cleanup-azure-resources.cmd -ResourceGroupName "my-rg" -Prefix "myapp"

rem Default parameters
set ResourceGroupName=assets-manager-rg
set Prefix=assetsapp

rem Parse command line arguments
:parse_args
if "%~1"=="" goto :end_parse_args
if /i "%~1"=="-ResourceGroupName" (
set ResourceGroupName=%~2
shift
shift
goto :parse_args
)
if /i "%~1"=="-Prefix" (
set Prefix=%~2
shift
shift
goto :parse_args
)
shift
goto :parse_args
:end_parse_args

echo ===========================================
echo Cleanup Azure Resources for Assets Manager
echo ===========================================
echo Resource Group to delete: %ResourceGroupName%
echo ===========================================
echo WARNING: This script will delete the entire resource group and all resources within it.
echo This action cannot be undone.
echo ===========================================

rem Check prerequisites
echo Checking Azure CLI installation...
where az >nul 2>&1
if %ERRORLEVEL% neq 0 (
echo Azure CLI not found. Please install it: https://docs.microsoft.com/cli/azure/install-azure-cli
exit /b 1
)

rem Check if resource group exists
echo Checking if resource group exists...
cmd /c az group show --name %ResourceGroupName% >nul 2>&1
if %ERRORLEVEL% neq 0 (
echo Resource group %ResourceGroupName% does not exist. Nothing to delete.
exit /b 0
)

echo Resource group %ResourceGroupName% found.
echo Deleting entire resource group...
cmd /c az group delete --name %ResourceGroupName% --yes
if %ERRORLEVEL% neq 0 (
echo Failed to delete resource group. Please check for errors.
exit /b 1
)

echo ===========================================
echo Resource group %ResourceGroupName% deletion completed.
echo All resources within the group have been removed.
echo Cleanup complete!
echo ===========================================
64 changes: 64 additions & 0 deletions asset-manager/scripts/cleanup-azure-resources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash

# Azure Resources Cleanup Script for Assets Manager
# Execute with: ./cleanup-azure-resources.sh -r "my-rg" -p "myapp"

# Default parameters
RESOURCE_GROUP_NAME="assets-manager-rg"
PREFIX="assetsapp"

# Parse command line arguments
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-r|--resource-group)
RESOURCE_GROUP_NAME="$2"
shift
shift
;;
-p|--prefix)
PREFIX="$2"
shift
shift
;;
*)
shift
;;
esac
done

echo "==========================================="
echo "Cleanup Azure Resources for Assets Manager"
echo "==========================================="
echo "Resource Group to delete: $RESOURCE_GROUP_NAME"
echo "==========================================="
echo "WARNING: This script will delete the entire resource group and all resources within it."
echo " This action cannot be undone."
echo "==========================================="

# Check prerequisites
echo "Checking Azure CLI installation..."
if ! command -v az &> /dev/null; then
echo "Azure CLI not found. Please install it: https://docs.microsoft.com/cli/azure/install-azure-cli"
exit 1
fi

# Check if resource group exists
echo "Checking if resource group exists..."
if ! az group show --name "$RESOURCE_GROUP_NAME" &> /dev/null; then
echo "Resource group $RESOURCE_GROUP_NAME does not exist. Nothing to delete."
exit 0
fi

echo "Resource group $RESOURCE_GROUP_NAME found."
echo "Deleting entire resource group..."
if ! az group delete --name "$RESOURCE_GROUP_NAME" --yes; then
echo "Failed to delete resource group. Please check for errors."
exit 1
fi

echo "==========================================="
echo "Resource group $RESOURCE_GROUP_NAME deletion completed."
echo "All resources within the group have been removed."
echo "Cleanup complete!"
echo "==========================================="
Loading