/
registerFeatures.sh
54 lines (42 loc) · 1.75 KB
/
registerFeatures.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
set -e
set -o nounset
set -o pipefail
# Check if Azure CLI is installed.
checkAzureCli() {
if ! command -v az &> /dev/null; then
echo "Error: 'az' command is not found. Please ensure Azure CLI is installed."
exit 1
else
echo "'az' command is available. Continuing with the script..."
fi
}
# Register a given Azure provider.
registerAzureProvider() {
local providerName="$1"
local providerDescription="$2"
echo "Starting registration for $providerDescription..."
if az provider register -n "$providerName"; then
echo "Successfully registered $providerDescription."
else
echo "Failed to register $providerDescription."
exit 1
fi
}
main() {
echo "Beginning Azure Resource Providers registration..."
# Check Azure CLI installation
checkAzureCli
# Define providers and their descriptions
local azureProviders=("Microsoft.VirtualMachineImages" "Microsoft.Compute" "Microsoft.KeyVault" "Microsoft.Storage" "Microsoft.Network" "Microsoft.DevCenter" "Microsoft.ContainerInstance")
local providerDescriptions=("Azure Resource Provider for Virtual Machine Images" "Azure Resource Provider for Compute" "Azure Resource Provider for Key Vault" "Azure Resource Provider for Storage" "Azure Resource Provider for Network" "Azure Resource Provider for Dev Center" "Azure Resource Provider for Container Instance")
# Register each provider
for index in "${!azureProviders[@]}"; do
registerAzureProvider "${azureProviders[$index]}" "${providerDescriptions[$index]}"
done
# Add devcenter extension
az extension add --name devcenter
echo "Azure Resource Providers registration process completed."
}
# Execute the main function
main