wtfutil/wtf · error

azure subscription ID is required but not configured

Error message

azure subscription ID is required but not configured

What it means

RunQuery in modules/azurelogs/query.go:40 throws this when QueryFile.SubscriptionID is empty. The subscription ID is needed both to select/create the Azure Logs client (LogQueryClients map is keyed by it) and to scope the query request. It is a deliberate early validation before touching the client cache.

Source

Thrown at modules/azurelogs/query.go:40

// TableResp represents the response from an Azure Log Analytics query
type TableResp struct {
	Header []string   // Column headers
	Rows   []TableRow // Data rows
}

// RunQuery executes an Azure Log Analytics query and returns the formatted results
func RunQuery(sess *Session) (*TableResp, error) {
	qf := sess.QueryFile
	var err error
	var tableResp TableResp
	tableResp.Header = qf.Columns

	if qf.WorkspaceID == "" {
		return nil, fmt.Errorf("azure workspace ID is required but not configured")
	}

	if qf.SubscriptionID == "" {
		return nil, fmt.Errorf("azure subscription ID is required but not configured")
	}

	// Use read lock first to check if client exists
	clientsMutex.RLock()
	client := LogQueryClients[qf.SubscriptionID]
	clientsMapExists := LogQueryClients != nil
	clientsMutex.RUnlock()

	// If map doesn't exist or client doesn't exist, we need write access
	if !clientsMapExists || client == nil {
		clientsMutex.Lock()
		// Double-check after acquiring write lock (double-checked locking pattern)
		if LogQueryClients == nil {
			LogQueryClients = make(map[string]*azquery.LogsClient)
		}

		if LogQueryClients[qf.SubscriptionID] == nil {
			LogQueryClients[qf.SubscriptionID], err = CreateLogsClient(sess, qf.SubscriptionID)

View on GitHub (pinned to bb838c1ccb)

Solutions

  1. Set subscription-id: <subscription-guid> in the query config YAML
  2. Confirm the yaml tag on QueryFile.SubscriptionID matches the key in the file
  3. Verify the subscription GUID is correct in the Azure portal and that it hosts the workspace
  4. Log the parsed QueryFile after Init to confirm all required IDs are populated

Example fix

// before (query.yml)
workspace-id: 00000000-0000-0000-0000-000000000000
// after (query.yml)
workspace-id: 00000000-0000-0000-0000-000000000000
subscription-id: 11111111-2222-3333-4444-555555555555
Defensive patterns

Strategy: validation

Validate before calling

if sess.QueryFile.SubscriptionID == "" {
    return errors.New("subscription-id missing in query config; set it before RunQuery")
}

Try / catch

tables, err := RunQuery(sess)
if err != nil {
    if strings.Contains(err.Error(), "subscription ID is required") {
        return fmt.Errorf("config: add subscription-id to %s", queryPath)
    }
    return err
}

Prevention

When it happens

Trigger: Calling RunQuery or fetchDataAsync when the query config YAML does not define subscription-id (or defines it empty), while workspace-id is present — the workspace check at line 36 passed first.

Common situations: Config file written for a different cloud/tenant missing the subscription key, placeholder value left unfilled, or case-mismatched YAML key versus the struct's yaml tag so the field stays zero-valued.

Related errors


AI-assisted analysis of wtfutil/wtf@bb838c1ccb (2026-09-03). Data as JSON: /api/errors/8e510b4a1568d95b. Report an issue: GitHub.