Skip to content

Commit abb1a75

Browse files
yiliuTomajguo
authored andcommitted
add scripts to deploy to azure
1 parent b96e669 commit abb1a75

File tree

4 files changed

+1350
-0
lines changed

4 files changed

+1350
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
@echo off
2+
setlocal enabledelayedexpansion
3+
4+
rem Azure Resources Cleanup Script for Assets Manager
5+
rem Execute with: cleanup-azure-resources.cmd -ResourceGroupName "my-rg" -Prefix "myapp"
6+
7+
rem Default parameters
8+
set ResourceGroupName=assets-manager-rg
9+
set Prefix=assetsapp
10+
11+
rem Parse command line arguments
12+
:parse_args
13+
if "%~1"=="" goto :end_parse_args
14+
if /i "%~1"=="-ResourceGroupName" (
15+
set ResourceGroupName=%~2
16+
shift
17+
shift
18+
goto :parse_args
19+
)
20+
if /i "%~1"=="-Prefix" (
21+
set Prefix=%~2
22+
shift
23+
shift
24+
goto :parse_args
25+
)
26+
shift
27+
goto :parse_args
28+
:end_parse_args
29+
30+
echo ===========================================
31+
echo Cleanup Azure Resources for Assets Manager
32+
echo ===========================================
33+
echo Resource Group to delete: %ResourceGroupName%
34+
echo ===========================================
35+
echo WARNING: This script will delete the entire resource group and all resources within it.
36+
echo This action cannot be undone.
37+
echo ===========================================
38+
39+
rem Check prerequisites
40+
echo Checking Azure CLI installation...
41+
where az >nul 2>&1
42+
if %ERRORLEVEL% neq 0 (
43+
echo Azure CLI not found. Please install it: https://docs.microsoft.com/cli/azure/install-azure-cli
44+
exit /b 1
45+
)
46+
47+
rem Check if resource group exists
48+
echo Checking if resource group exists...
49+
cmd /c az group show --name %ResourceGroupName% >nul 2>&1
50+
if %ERRORLEVEL% neq 0 (
51+
echo Resource group %ResourceGroupName% does not exist. Nothing to delete.
52+
exit /b 0
53+
)
54+
55+
echo Resource group %ResourceGroupName% found.
56+
echo Deleting entire resource group...
57+
cmd /c az group delete --name %ResourceGroupName% --yes
58+
if %ERRORLEVEL% neq 0 (
59+
echo Failed to delete resource group. Please check for errors.
60+
exit /b 1
61+
)
62+
63+
echo ===========================================
64+
echo Resource group %ResourceGroupName% deletion completed.
65+
echo All resources within the group have been removed.
66+
echo Cleanup complete!
67+
echo ===========================================
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash
2+
3+
# Azure Resources Cleanup Script for Assets Manager
4+
# Execute with: ./cleanup-azure-resources.sh -r "my-rg" -p "myapp"
5+
6+
# Default parameters
7+
RESOURCE_GROUP_NAME="assets-manager-rg"
8+
PREFIX="assetsapp"
9+
10+
# Parse command line arguments
11+
while [[ $# -gt 0 ]]; do
12+
key="$1"
13+
case $key in
14+
-r|--resource-group)
15+
RESOURCE_GROUP_NAME="$2"
16+
shift
17+
shift
18+
;;
19+
-p|--prefix)
20+
PREFIX="$2"
21+
shift
22+
shift
23+
;;
24+
*)
25+
shift
26+
;;
27+
esac
28+
done
29+
30+
echo "==========================================="
31+
echo "Cleanup Azure Resources for Assets Manager"
32+
echo "==========================================="
33+
echo "Resource Group to delete: $RESOURCE_GROUP_NAME"
34+
echo "==========================================="
35+
echo "WARNING: This script will delete the entire resource group and all resources within it."
36+
echo " This action cannot be undone."
37+
echo "==========================================="
38+
39+
# Check prerequisites
40+
echo "Checking Azure CLI installation..."
41+
if ! command -v az &> /dev/null; then
42+
echo "Azure CLI not found. Please install it: https://docs.microsoft.com/cli/azure/install-azure-cli"
43+
exit 1
44+
fi
45+
46+
# Check if resource group exists
47+
echo "Checking if resource group exists..."
48+
if ! az group show --name "$RESOURCE_GROUP_NAME" &> /dev/null; then
49+
echo "Resource group $RESOURCE_GROUP_NAME does not exist. Nothing to delete."
50+
exit 0
51+
fi
52+
53+
echo "Resource group $RESOURCE_GROUP_NAME found."
54+
echo "Deleting entire resource group..."
55+
if ! az group delete --name "$RESOURCE_GROUP_NAME" --yes; then
56+
echo "Failed to delete resource group. Please check for errors."
57+
exit 1
58+
fi
59+
60+
echo "==========================================="
61+
echo "Resource group $RESOURCE_GROUP_NAME deletion completed."
62+
echo "All resources within the group have been removed."
63+
echo "Cleanup complete!"
64+
echo "==========================================="

0 commit comments

Comments
 (0)