create-resource-group
Define and organize Azure resources by establishing a resource group with specific name, location, and optional tags for streamlined management.
Instructions
Create a new resource group
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| location | Yes | Azure region | |
| name | Yes | Resource group name | |
| tags | No | Resource tags (optional) |
Input Schema (JSON Schema)
{
"properties": {
"location": {
"description": "Azure region",
"type": "string"
},
"name": {
"description": "Resource group name",
"type": "string"
},
"tags": {
"description": "Resource tags (optional)",
"type": "object"
}
},
"required": [
"name",
"location"
],
"type": "object"
}
Implementation Reference
- src/AzureServer.ts:647-686 (handler)Primary handler method for 'create-resource-group' tool. Validates input parameters using Zod and calls AzureOperations.createResourceGroup to perform the creation.private async handleCreateResourceGroup(args: any) { const { name, location, tags } = z .object({ name: z.string().min(1, "Resource group name cannot be empty"), location: z.string().min(1, "Location cannot be empty"), tags: z.record(z.string()).optional(), }) .parse(args); if (!this.context.resourceClient) { throw new AzureMCPError("Client not initialized", "NO_CLIENT"); } try { // Use azureOperations to create the resource group const result = await this.azureOperations.createResourceGroup( name, location, tags ); // Invalidate cache for resource groups list this.resourceCache.delete( `resource-groups-${this.context.selectedSubscription}` ); return { id: result.id, name: result.name, location: result.location, tags: result.tags || {}, provisioningState: result.properties?.provisioningState, }; } catch (error) { this.logWithContext("error", `Error creating resource group: ${error}`, { error, }); throw new AzureResourceError(`Failed to create resource group: ${error}`); } }
- src/AzureServer.ts:992-1005 (handler)Core implementation in AzureOperations class that executes the Azure SDK call to create or update the resource group.async createResourceGroup( name: string, location: string, tags?: Record<string, string> ) { if (!this.context.resourceClient) { throw new AzureMCPError("Client not initialized", "NO_CLIENT"); } return await this.context.resourceClient.resourceGroups.createOrUpdate( name, { location, tags } ); }
- src/AzureServer.ts:377-397 (schema)Input schema definition for the 'create-resource-group' tool, defining parameters name, location, and optional tags.name: "create-resource-group", description: "Create a new resource group", inputSchema: { type: "object", properties: { name: { type: "string", description: "Resource group name", }, location: { type: "string", description: "Azure region", }, tags: { type: "object", description: "Resource tags (optional)", }, }, required: ["name", "location"], }, },
- src/AzureServer.ts:451-453 (registration)Switch case in handleCallTool that registers and routes calls to the 'create-resource-group' handler.case "create-resource-group": result = await this.handleCreateResourceGroup(args); break;