This PowerShell script automates the creation of Azure resources such as resource groups, virtual networks, and subnets. It's designed for users who want to streamline the setup of a basic networking infrastructure in Azure.
- Resource Group Creation: Automatically creates a new Azure resource group in the specified location.
- Virtual Network Configuration: Creates a virtual network with a custom address space.
- Subnet Creation: Adds a subnet configuration to the virtual network.
Before using this script, ensure you have the following:
-
Azure PowerShell Module: Installed and updated. Use the following command to install it:
Install-Module -Name Az -AllowClobber -Scope CurrentUser
-
Azure Account Access: Logged in to your Azure account. Use the following command to log in:
Connect-AzAccount
-
Edit the Script: Open the script file and modify the following variables to suit your environment:
$resourceGroupName: The name of the resource group to be created.$location: The Azure region where the resources will be deployed (e.g.,East US).$virtualNetworkName: Name of the virtual network.$addressPrefix: Address space for the virtual network.$subnetName: Name of the subnet.$subnetPrefix: Address range for the subnet.
-
Run the Script: Execute the script in PowerShell:
.mPowerShell.ps1
-
Verify Resources: Once the script completes, verify the resources in the Azure portal or using Azure CLI.
The default configuration creates:
- A resource group named
MyResourceGroupin theEast USregion. - A virtual network named
MyVnetwith an address space of10.0.0.0/16. - A subnet named
MySubnetwith an address range of10.0.0.0/24.
You can extend the script to include additional resources such as:
- Virtual machines
- Network security groups
- Public IP addresses
Refer to the Azure PowerShell Documentation for more details.
- Module Not Found: Ensure the Az module is installed and imported correctly.
- Insufficient Permissions: Verify your Azure account has the necessary permissions to create resources.
- Invalid Parameters: Check that all parameters (e.g., location, address space) are valid.
This script is provided "as-is" under the MIT License. See the LICENSE file for more details.
Happy automating with Azure! 🎉