wtfutil/wtf · error

azure workspace ID is required but not configured

Error message

azure workspace ID is required but not configured

What it means

RunQuery in modules/azurelogs/query.go:36 refuses to run when the parsed QueryFile has an empty WorkspaceID. The workspace ID identifies the Azure Log Analytics workspace to query, so without it the API call would be invalid. The library throws this as an explicit pre-flight validation before any Azure API call.

Source

Thrown at modules/azurelogs/query.go:36

// TableRow represents a single row of data from Azure Log Analytics
type TableRow []string

// 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)

View on GitHub (pinned to bb838c1ccb)

Solutions

  1. Add the workspace ID to the query config YAML (e.g. workspace-id: <guid>) and re-run Init
  2. Verify the yaml tag on the WorkspaceID struct field matches the key used in the config file
  3. Check that any env-var placeholder in the config (e.g. ${WORKSPACE_ID}) is actually set in the environment
  4. Print/log sess.QueryFile after Init to confirm the field was parsed

Example fix

// before (query.yml)
subscription-id: abc-123
query: "AzureActivity | take 10"
// after (query.yml)
workspace-id: 00000000-0000-0000-0000-000000000000
subscription-id: abc-123
query: "AzureActivity | take 10"
Defensive patterns

Strategy: validation

Validate before calling

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

Try / catch

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

Prevention

When it happens

Trigger: Calling RunQuery (directly or via fetchDataAsync) when the session's QueryFile.WorkspaceID is the empty string — i.e. the query config YAML omitted the workspace ID key or set it to an empty value.

Common situations: Query config file missing the workspace-id field, empty value after an environment-variable substitution that did not resolve, or a struct with wrong yaml tags so the field never gets populated during unmarshal.

Related errors


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