VictoriaMetrics/VictoriaMetrics · error
cannot create client for %q: %w
Error message
cannot create client for %q: %w
What it means
After obtaining a refresh token function, newAPIConfig builds an HTTP client for the Azure Resource Manager endpoint with discoveryutil.NewClient. If client construction fails (bad proxy URL, TLS/auth config problems), the error is wrapped with the ResourceManager endpoint name in this message.
Source
Thrown at lib/promscrape/discovery/azure/api.go:118
return nil, fmt.Errorf("cannot parse proxy auth config: %w", err)
}
environment := sdc.Environment
if environment == "" {
environment = "AZURECLOUD"
}
env, err := getCloudEnvByName(environment)
if err != nil {
return nil, fmt.Errorf("cannot read configs for `environment: %q`: %w", environment, err)
}
refreshToken, err := getRefreshTokenFunc(sdc, ac, proxyAC, env)
if err != nil {
return nil, err
}
c, err := discoveryutil.NewClient(env.ResourceManagerEndpoint, ac, sdc.ProxyURL, proxyAC, &sdc.HTTPClientConfig)
if err != nil {
return nil, fmt.Errorf("cannot create client for %q: %w", env.ResourceManagerEndpoint, err)
}
// It's already verified in discoveryutil.NewClient so no need to check err.
u, _ := url.Parse(c.APIServer())
cfg := &apiConfig{
c: c,
apiServerHost: u.Hostname(),
port: port,
resourceGroup: sdc.ResourceGroup,
subscriptionID: sdc.SubscriptionID,
tenantID: sdc.TenantID,
refreshToken: refreshToken,
}
return cfg, nil
}
func getCloudEnvByName(name string) (*cloudEnvironmentEndpoints, error) {View on GitHub (pinned to 5079fb58f1)
Solutions
- Read the wrapped underlying error for the precise cause
- Fix the `proxy_url` value (must be a valid absolute URL)
- Check all file paths in the `http_client_config` TLS section exist and are readable
- Remove unnecessary auth/TLS options if connecting directly to Azure public endpoints
Example fix
# before proxy_url: "proxy.corp.local:3128" # after proxy_url: "http://proxy.corp.local:3128"
Defensive patterns
Strategy: validation
Prevention
- Use absolute proxy URLs with scheme
When it happens
Trigger: discoveryutil.NewClient(env.ResourceManagerEndpoint, ac, sdc.ProxyURL, proxyAC, &sdc.HTTPClientConfig) returns an error: invalid `proxy_url`, bad HTTP client config/TLS settings, or invalid endpoint URL parsing.
Common situations: Malformed `proxy_url` (missing scheme), self-signed CA files not present, or HTTPClientConfig options like oauth2 misconfigured for the Azure endpoint.
Related errors
- missing directory on the AZBlob container %q
- cannot initialize connection to AZBlob: %w
- cannot list blobs at %s (remote path %q): %w
- cannot start async copy %q from %s to %s: %w
- failed to check copy status, cannot get properties of %q at
AI-assisted analysis of VictoriaMetrics/VictoriaMetrics@5079fb58f1 (2026-09-03).
Data as JSON: /api/errors/0f54d62f69abc2ed.
Report an issue: GitHub.