-
Notifications
You must be signed in to change notification settings - Fork 1
Configuration Guide
Hazem Ali edited this page Jun 11, 2025
·
1 revision
This guide covers all configuration options available in the AzureImage SDK.
var options = new AzureImageOptions
{
Endpoint = "your-endpoint",
ApiKey = "your-api-key",
ApiVersion = "2024-02-15-preview",
RetryPolicy = RetryPolicy.Default,
Timeout = TimeSpan.FromSeconds(30)
};| Property | Type | Description | Default |
|---|---|---|---|
| Endpoint | string | Azure AI Foundry endpoint URL | Required |
| ApiKey | string | API key for authentication | Required |
| ApiVersion | string | API version to use | "2024-02-15-preview" |
| RetryPolicy | RetryPolicy | Retry policy configuration | Default |
| Timeout | TimeSpan | Request timeout | 30 seconds |
var options = new AzureImageOptions
{
Endpoint = "your-endpoint",
ApiKey = "your-api-key",
RetryPolicy = new RetryPolicy
{
MaxRetries = 3,
RetryDelay = TimeSpan.FromSeconds(1),
MaxDelay = TimeSpan.FromSeconds(10)
}
};var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Add("User-Agent", "MyApp/1.0");
var options = new AzureImageOptions
{
Endpoint = "your-endpoint",
ApiKey = "your-api-key",
HttpClient = httpClient
};{
"AzureImage": {
"Endpoint": "your-endpoint",
"ApiKey": "your-api-key",
"ApiVersion": "2024-02-15-preview",
"Timeout": "00:00:30"
}
}public void ConfigureServices(IServiceCollection services)
{
services.AddAzureImage(options =>
{
options.Endpoint = Configuration["AzureImage:Endpoint"];
options.ApiKey = Configuration["AzureImage:ApiKey"];
options.ApiVersion = Configuration["AzureImage:ApiVersion"];
options.Timeout = TimeSpan.Parse(Configuration["AzureImage:Timeout"]);
});
}The SDK can be configured using environment variables:
AZURE_IMAGE_ENDPOINT=your-endpoint
AZURE_IMAGE_API_KEY=your-api-key
AZURE_IMAGE_API_VERSION=2024-02-15-preview
AZURE_IMAGE_TIMEOUT=00:00:30var ultraOptions = new StableImageUltraOptions
{
Endpoint = "your-ultra-endpoint",
ApiKey = "your-api-key",
ApiVersion = "2024-02-15-preview",
DefaultSize = new ImageSize(1024, 1024),
DefaultQuality = ImageQuality.High
};var coreOptions = new StableImageCoreOptions
{
Endpoint = "your-core-endpoint",
ApiKey = "your-api-key",
ApiVersion = "2024-02-15-preview",
DefaultSize = new ImageSize(512, 512),
DefaultQuality = ImageQuality.Standard
};- Store API keys in secure configuration management systems
- Use environment variables or Azure Key Vault in production
- Rotate API keys regularly
- Use different API keys for different environments
- Use HTTPS for all communications
- Configure appropriate firewall rules
- Use private endpoints when available
- Monitor and log all API access
-
Configuration Management
- Use different configurations for different environments
- Never commit sensitive information to source control
- Use secure configuration management systems
-
Performance
- Configure appropriate timeouts
- Use retry policies for transient failures
- Monitor and adjust configuration based on usage patterns
-
Error Handling
- Configure appropriate retry policies
- Implement proper error handling
- Log configuration-related issues
Common configuration issues and solutions:
-
Invalid Endpoint
- Verify the endpoint URL format
- Check network connectivity
- Ensure the endpoint is accessible
-
Authentication Failures
- Verify API key is correct
- Check API key permissions
- Ensure API key is not expired
-
Timeout Issues
- Adjust timeout settings
- Check network latency
- Monitor request duration
If you need help with configuration: