-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Using the API V1
- Overview
- Authentication
- Interactive Documentation (Swagger UI)
- Getting Started
- Core Endpoints
- Name Generation API
- Configuration Endpoints
- Administrative Endpoints
- Response Formats
- Best Practices
- Error Handling
- Rate Limiting
- Migration to V2
- Examples
The Azure Naming Tool API Version 1.0 provides programmatic access to generate standardized Azure resource names based on your organization's naming conventions. The API allows you to:
- Generate resource names using configured naming patterns
- Validate resource names against Azure naming rules
- Manage naming convention components (environments, locations, resource types, etc.)
- Export and import configurations
- Access naming history and logs
The V1 API is production-ready and stable. For new integrations, consider using API V2 which offers enhanced features, standardized responses, and Azure tenant validation.
The Azure Naming Tool uses API key authentication with three distinct key types, each providing different levels of access:
Purpose: Complete administrative access to all API endpoints
Permissions:
- ✅ All GET endpoints (read access)
- ✅ All POST endpoints (write access)
- ✅ Name generation endpoints
- ✅ Configuration management (create, update, delete)
- ✅ Administrative functions (password changes, key management)
- ✅ Import/Export operations
Use Cases:
- Full system integration
- Administrative automation
- Configuration management scripts
- Complete CI/CD pipeline integration
Security Note: This key provides unrestricted access. Store securely and rotate regularly.
Purpose: Limited access for name generation only
Permissions:
- ✅ Name generation endpoints (
RequestName,RequestNameWithComponents) - ✅ Name validation endpoint (
ValidateName) - ✅ Read-only access to configuration endpoints (GET requests)
- ❌ Configuration modifications (POST to config endpoints)
- ❌ Administrative functions
Use Cases:
- CI/CD pipelines (generate names during deployments)
- Infrastructure-as-Code (IaC) tools (Terraform, Bicep, ARM templates)
- Automated provisioning scripts
- Developer tools and utilities
Security Note: Recommended for most automation scenarios. Prevents accidental configuration changes.
Purpose: View-only access to configurations
Permissions:
- ✅ All GET endpoints (read configuration data)
- ❌ Name generation endpoints
- ❌ All POST endpoints (no write access)
- ❌ Configuration modifications
- ❌ Administrative functions
Use Cases:
- Auditing and reporting
- Configuration monitoring
- Documentation generation
- External integrations requiring configuration visibility
Security Note: Safest key type for third-party integrations and read-only access scenarios.
-
Access the Admin Portal
- Navigate to the Azure Naming Tool web interface
- Log in with the Global Admin Password
-
Generate/View API Keys
- Go to Configuration → Admin
- View or generate the three API key types
- Copy and securely store the keys
Include the API key in the APIKey header for all requests:
GET /api/ResourceTypes HTTP/1.1
Host: your-naming-tool.azurewebsites.net
APIKey: your-api-key-here
Content-Type: application/jsonUse the Admin endpoints to update keys (requires Global Admin Password):
POST /api/Admin/UpdateAPIKey HTTP/1.1
Host: your-naming-tool.azurewebsites.net
AdminPassword: your-global-admin-password
Content-Type: application/json
"new-api-key-value"The Azure Naming Tool includes Swagger UI for interactive API documentation and testing.
Navigate to: https://your-naming-tool-url/swagger
- Interactive API Explorer: Test all endpoints directly from the browser
- Request/Response Examples: View sample payloads and responses
- Schema Documentation: Explore request and response models
- Authentication Testing: Test different API keys and permissions
- Response Codes: View all possible HTTP status codes for each endpoint
- Authorize: Click the "Authorize" button and enter your API key
- Explore Endpoints: Browse endpoints by category
- Try It Out: Click "Try it out" on any endpoint
- Execute: Fill in parameters and click "Execute"
- View Response: See the actual API response and status code
Tip: Use Swagger UI to understand request/response formats before implementing API calls in your code.
Format: https://{your-naming-tool-host}/api
Examples:
- Azure App Service:
https://your-naming-tool.azurewebsites.net/api - Docker:
http://localhost:8081/api - Custom Domain:
https://naming.yourdomain.com/api
V1 endpoints do NOT include a version number in the URL path:
https://your-naming-tool.azurewebsites.net/api/ResourceNamingRequests/RequestName
For V2 endpoints, see the API V2 documentation.
Required Headers:
APIKey: your-api-key-here
Content-Type: application/jsonOptional Headers:
Accept: application/json| Endpoint | Method | Description | API Key Required |
|---|---|---|---|
/api/ResourceNamingRequests/RequestName |
POST | Generate name with simple format (recommended) | Name Generation or Full Access |
/api/ResourceNamingRequests/RequestNameWithComponents |
POST | Generate name with full component definition | Name Generation or Full Access |
/api/ResourceNamingRequests/ValidateName |
POST | Validate a name against resource type regex | Name Generation or Full Access |
The ValidateName endpoint validates names using Azure resource type regex patterns (NOT the tool's configuration).
All configuration endpoints support:
- GET (list all items): Requires any API key
- POST (create/update): Requires Full Access API key
Configuration categories:
- Resource Types
- Resource Locations
- Resource Environments
- Resource Organizations
- Resource Unit/Departments
- Resource Functions
- Resource Project/App/Services
- Custom Components
- Resource Delimiters
Endpoint: POST /api/ResourceNamingRequests/RequestName
Description: Generate a resource name using simplified request format. This is the recommended method for most scenarios.
API Key: Name Generation API Access Key or Full API Access Key
Request Body:
{
"resourceEnvironment": "prod",
"resourceFunction": "data",
"resourceInstance": "001",
"resourceLocation": "eastus",
"resourceOrg": "contoso",
"resourceProjAppSvc": "webapp",
"resourceType": "vnet",
"resourceUnitDept": "marketing"
}Field Descriptions:
| Field | Type | Required | Description |
|---|---|---|---|
resourceType |
string | ✅ Yes | The short name of the Azure resource type (e.g., "vnet", "st", "kv") |
resourceEnvironment |
string | Optional | Environment identifier (e.g., "prod", "dev", "test") |
resourceLocation |
string | Optional | Azure region short name (e.g., "eastus", "westeu") |
resourceOrg |
string | Optional | Organization identifier |
resourceUnitDept |
string | Optional | Business unit or department |
resourceFunction |
string | Optional | Resource function/purpose (e.g., "data", "app", "web") |
resourceProjAppSvc |
string | Optional | Project, application, or service name |
resourceInstance |
string | Optional | Instance number (e.g., "001", "002") |
Success Response (200 OK):
{
"resourceName": "vnet-contoso-marketing-webapp-data-prod-eastus-001",
"message": "Name generation successful!",
"success": true
}Error Response (400 Bad Request):
{
"resourceName": "",
"message": "Resource type 'invalid-type' not found",
"success": false
}Example (cURL):
curl -X POST "https://your-naming-tool.azurewebsites.net/api/ResourceNamingRequests/RequestName" \
-H "APIKey: your-name-gen-api-key" \
-H "Content-Type: application/json" \
-d '{
"resourceType": "vnet",
"resourceEnvironment": "prod",
"resourceLocation": "eastus",
"resourceInstance": "001"
}'Example (PowerShell):
$headers = @{
"APIKey" = "your-name-gen-api-key"
"Content-Type" = "application/json"
}
$body = @{
resourceType = "vnet"
resourceEnvironment = "prod"
resourceLocation = "eastus"
resourceInstance = "001"
} | ConvertTo-Json
Invoke-RestMethod -Uri "https://your-naming-tool.azurewebsites.net/api/ResourceNamingRequests/RequestName" `
-Method Post `
-Headers $headers `
-Body $bodyExample (Python):
import requests
import json
url = "https://your-naming-tool.azurewebsites.net/api/ResourceNamingRequests/RequestName"
headers = {
"APIKey": "your-name-gen-api-key",
"Content-Type": "application/json"
}
data = {
"resourceType": "vnet",
"resourceEnvironment": "prod",
"resourceLocation": "eastus",
"resourceInstance": "001"
}
response = requests.post(url, headers=headers, json=data)
print(response.json())Endpoint: POST /api/ResourceNamingRequests/RequestNameWithComponents
Description: Generate a resource name with full component object definitions. Use this when you need precise control over component IDs and values.
API Key: Name Generation API Access Key or Full API Access Key
Request Body:
{
"resourceComponents": [
{
"id": 1,
"name": "Resource Type",
"value": "vnet"
},
{
"id": 2,
"name": "Resource Environment",
"value": "prod"
},
{
"id": 3,
"name": "Resource Location",
"value": "eastus"
},
{
"id": 4,
"name": "Resource Instance",
"value": "001"
}
]
}Success Response (200 OK):
{
"resourceName": "vnet-prod-eastus-001",
"message": "Name generation successful!",
"success": true
}Note: This method requires knowledge of component IDs and exact naming. For most scenarios, use RequestName instead.
Endpoint: POST /api/ResourceNamingRequests/ValidateName
Description: Validate a resource name against the Azure resource type regex pattern. This does NOT validate against the tool's configuration, only against Azure's naming rules.
API Key: Name Generation API Access Key or Full API Access Key
Request Body:
{
"resourceType": "vnet",
"name": "vnet-contoso-prod-eastus-001"
}Success Response (200 OK):
{
"valid": true,
"message": "Name is valid for resource type 'vnet'"
}Invalid Name Response (200 OK):
{
"valid": false,
"message": "Name violates Azure naming rules: must be lowercase alphanumeric with hyphens"
}Example (cURL):
curl -X POST "https://your-naming-tool.azurewebsites.net/api/ResourceNamingRequests/ValidateName" \
-H "APIKey: your-name-gen-api-key" \
-H "Content-Type: application/json" \
-d '{
"resourceType": "vnet",
"name": "vnet-contoso-prod-eastus-001"
}'All configuration endpoints follow a consistent pattern:
List All: GET /api/ResourceTypes
Example Response:
[
{
"id": 1,
"resource": "Virtual Network",
"shortName": "vnet",
"scope": "resource group",
"lengthMin": 2,
"lengthMax": 64,
"validText": "Alphanumerics, underscores, periods, and hyphens.",
"regx": "^[a-zA-Z0-9][a-zA-Z0-9-._]{0,62}[a-zA-Z0-9_]$",
"enabled": true
}
]API Key: Any (Read-Only, Name Generation, or Full Access)
List All: GET /api/ResourceLocations
Example Response:
[
{
"id": 1,
"name": "East US",
"shortName": "eastus",
"enabled": true
}
]API Key: Any (Read-Only, Name Generation, or Full Access)
List All: GET /api/ResourceEnvironments
Example Response:
[
{
"id": 1,
"name": "Production",
"shortName": "prod",
"enabled": true
},
{
"id": 2,
"name": "Development",
"shortName": "dev",
"enabled": true
}
]API Key: Any (Read-Only, Name Generation, or Full Access)
List All: GET /api/ResourceOrgs
Example Response:
[
{
"id": 1,
"name": "Contoso Corporation",
"shortName": "contoso",
"enabled": true
}
]API Key: Any (Read-Only, Name Generation, or Full Access)
List All: GET /api/ResourceUnitDepts
Example Response:
[
{
"id": 1,
"name": "Marketing",
"shortName": "marketing",
"enabled": true
}
]API Key: Any (Read-Only, Name Generation, or Full Access)
List All: GET /api/ResourceFunctions
Example Response:
[
{
"id": 1,
"name": "Data",
"shortName": "data",
"enabled": true
}
]API Key: Any (Read-Only, Name Generation, or Full Access)
List All: GET /api/ResourceProjAppSvcs
Example Response:
[
{
"id": 1,
"name": "Web Application",
"shortName": "webapp",
"enabled": true
}
]API Key: Any (Read-Only, Name Generation, or Full Access)
List All: GET /api/CustomComponents
Example Response:
[
{
"id": 1,
"name": "Region Code",
"shortName": "us",
"enabled": true
}
]API Key: Any (Read-Only, Name Generation, or Full Access)
List All: GET /api/ResourceDelimiters
Example Response:
[
{
"id": 1,
"name": "Hyphen",
"delimiter": "-",
"enabled": true
}
]API Key: Any (Read-Only, Name Generation, or Full Access)
Update Password: POST /api/Admin/UpdatePassword
Headers:
AdminPassword: current-global-admin-password
Content-Type: application/jsonRequest Body:
"new-password"Response: "SUCCESS" or "FAILURE - ..."
Update Full API Key: POST /api/Admin/UpdateAPIKey
Headers:
AdminPassword: current-global-admin-password
Content-Type: application/jsonRequest Body:
"new-api-key"Response: "SUCCESS" or "FAILURE - ..."
List Generated Names: GET /api/Admin/GetGeneratedNames
API Key: Full API Access Key
Example Response:
[
{
"id": 1,
"resourceName": "vnet-contoso-prod-eastus-001",
"resourceType": "vnet",
"createdBy": "API",
"createdOn": "2025-01-15T10:30:00Z"
}
]Export Configuration: GET /api/ImportExport/ExportConfig
API Key: Full API Access Key
Response: JSON configuration file download
Import Configuration: POST /api/ImportExport/ImportConfig
API Key: Full API Access Key
Request Body: Multipart form data with configuration JSON file
Name generation endpoints return:
{
"resourceName": "vnet-contoso-prod-eastus-001",
"message": "Name generation successful!",
"success": true
}Configuration endpoints (GET) return arrays of objects:
[
{ "id": 1, "name": "...", "shortName": "...", "enabled": true }
]401 Unauthorized (Invalid/Missing API Key):
"Api Key was not provided!"
or
"Api Key is not valid!"
400 Bad Request (Invalid Request):
{
"resourceName": "",
"message": "Resource type 'invalid-type' not found",
"success": false
}500 Internal Server Error:
"Error message describing the issue"
- CI/CD Pipelines: Use Name Generation API Access Key
- Read-Only Tools: Use Read-Only API Access Key
- Full Administration: Use Full API Access Key (securely)
The RequestName endpoint is simpler and recommended for most use cases. Use RequestNameWithComponents only when you need precise component ID control.
Configuration data (resource types, locations, etc.) changes infrequently. Cache this data to reduce API calls.
Always check the success field in responses and handle errors appropriately:
response = requests.post(url, headers=headers, json=data)
result = response.json()
if result.get("success"):
name = result["resourceName"]
print(f"Generated name: {name}")
else:
error_message = result.get("message", "Unknown error")
print(f"Error: {error_message}")- Use environment variables or secret management systems (Azure Key Vault, AWS Secrets Manager)
- Never commit API keys to source control
- Rotate keys regularly
Always use HTTPS in production to protect API keys during transmission.
Validate resource types and component values against your configuration before making API calls to reduce errors.
| Error Code | Scenario | Solution |
|---|---|---|
| 401 Unauthorized | Missing or invalid API key | Verify API key is correct and included in headers |
| 400 Bad Request | Invalid resource type | Check resource type against configured types |
| 400 Bad Request | Missing required fields | Ensure resourceType is provided |
| 500 Internal Server Error | Server error | Check server logs, contact administrator |
Implement exponential backoff for transient errors:
import time
import requests
def generate_name_with_retry(url, headers, data, max_retries=3):
for attempt in range(max_retries):
try:
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
return response.json()
elif response.status_code in [500, 502, 503]:
# Transient error - retry
time.sleep(2 ** attempt) # Exponential backoff
else:
# Permanent error - don't retry
return response.json()
except requests.exceptions.RequestException as e:
time.sleep(2 ** attempt)
raise Exception("Max retries exceeded")The V1 API does not currently enforce rate limiting. However, best practices recommend:
- Limit concurrent requests to 10-20 per second
- Cache configuration data
- Use batch operations when available
- Implement client-side throttling
Consider migrating to API V2 for:
✅ Standardized Response Format: Consistent ApiResponse<T> wrapper
✅ Enhanced Error Handling: Detailed error codes and messages
✅ Azure Tenant Validation: Real-time name conflict detection
✅ Correlation IDs: Better request tracking and debugging
✅ Improved HTTP Status Codes: Proper use of 400, 401, 500 codes
✅ Metadata: Timestamps, versioning, and pagination support
Migration is straightforward - V2 endpoints have the same functionality with enhanced response formats.
# Configuration
$apiUrl = "https://your-naming-tool.azurewebsites.net/api/ResourceNamingRequests/RequestName"
$apiKey = "your-name-gen-api-key"
# Request data
$body = @{
resourceType = "vnet"
resourceEnvironment = "prod"
resourceLocation = "eastus"
resourceOrg = "contoso"
resourceInstance = "001"
} | ConvertTo-Json
# Headers
$headers = @{
"APIKey" = $apiKey
"Content-Type" = "application/json"
}
# Make request
$response = Invoke-RestMethod -Uri $apiUrl -Method Post -Headers $headers -Body $body
# Output
if ($response.success) {
Write-Host "Generated name: $($response.resourceName)"
} else {
Write-Error "Error: $($response.message)"
}import requests
url = "https://your-naming-tool.azurewebsites.net/api/ResourceTypes"
headers = {
"APIKey": "your-readonly-api-key"
}
response = requests.get(url, headers=headers)
resource_types = response.json()
# Print enabled resource types
for rt in resource_types:
if rt["enabled"]:
print(f"{rt['resource']} ({rt['shortName']})")# Call Azure Naming Tool API from Terraform
data "http" "resource_name" {
url = "https://your-naming-tool.azurewebsites.net/api/ResourceNamingRequests/RequestName"
method = "POST"
request_headers = {
APIKey = var.naming_tool_api_key
Content-Type = "application/json"
}
request_body = jsonencode({
resourceType = "vnet"
resourceEnvironment = "prod"
resourceLocation = "eastus"
resourceInstance = "001"
})
}
locals {
vnet_name = jsondecode(data.http.resource_name.response_body).resourceName
}
resource "azurerm_virtual_network" "example" {
name = local.vnet_name
location = "eastus"
resource_group_name = azurerm_resource_group.example.name
address_space = ["10.0.0.0/16"]
}# azure-pipelines.yml
trigger:
- main
variables:
namingToolUrl: 'https://your-naming-tool.azurewebsites.net/api'
namingToolApiKey: $(NamingToolApiKey) # Store in Azure DevOps secure variables
steps:
- task: PowerShell@2
displayName: 'Generate Resource Name'
inputs:
targetType: 'inline'
script: |
$body = @{
resourceType = "st"
resourceEnvironment = "$(Environment)"
resourceLocation = "$(Location)"
resourceInstance = "001"
} | ConvertTo-Json
$headers = @{
"APIKey" = "$(namingToolApiKey)"
"Content-Type" = "application/json"
}
$response = Invoke-RestMethod -Uri "$(namingToolUrl)/ResourceNamingRequests/RequestName" `
-Method Post `
-Headers $headers `
-Body $body
Write-Host "##vso[task.setvariable variable=StorageAccountName]$($response.resourceName)"
- task: AzureCLI@2
displayName: 'Create Storage Account'
inputs:
azureSubscription: 'Azure-Subscription'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
az storage account create \
--name $(StorageAccountName) \
--resource-group my-rg \
--location $(Location) \
--sku Standard_LRS-
Swagger UI:
https://your-naming-tool-url/swagger(interactive API documentation) - API V2 Documentation: Using the API V2 (enhanced features)
- Azure Validation Guide: Azure Validation WIKI (V2 feature)
- GitHub Repository: Azure Naming Tool
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: GitHub Wiki
Last Updated: January 2025
API Version: 1.0
Tool Version: 5.0.0+