Skip to content

Conversation

@khushboo9024
Copy link
Contributor

@khushboo9024 khushboo9024 commented Oct 16, 2025

Integration test logs

Logs
Add passing integration test logs here

Example query results

Results
> select
  subscription_id,
  display_name,
  default_tenant_policy ->> 'id' as policy_id,
  default_tenant_policy -> 'properties' ->> 'blockSubscriptionsLeavingTenant' as block_leaving_tenant,
  default_tenant_policy -> 'properties' ->> 'blockSubscriptionsIntoTenant' as block_into_tenant,
  default_tenant_policy -> 'properties' -> 'exemptedPrincipals' as exempted_principals
from
  azure_subscription;
+--------------------------------------+-----------------+---------------------------------------------------+----------------------+-------------------+------------>
| subscription_id                      | display_name    | policy_id                                         | block_leaving_tenant | block_into_tenant | exempted_pr>
+--------------------------------------+-----------------+---------------------------------------------------+----------------------+-------------------+------------>
| xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | newwarriors AAA | providers/Microsoft.Subscription/policies/default | false                | false             | []         >
| xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | Parker AAA      | providers/Microsoft.Subscription/policies/default | false                | false             | []         >
+--------------------------------------+-----------------+---------------------------------------------------+----------------------+-------------------+------------

@khushboo9024 khushboo9024 self-assigned this Oct 16, 2025
@khushboo9024 khushboo9024 marked this pull request as draft October 16, 2025 10:20
@khushboo9024 khushboo9024 marked this pull request as ready for review October 17, 2025 06:08
@khushboo9024 khushboo9024 requested a review from misraved October 17, 2025 06:08
@khushboo9024 khushboo9024 linked an issue Oct 17, 2025 that may be closed by this pull request
@khushboo9024 khushboo9024 requested a review from Copilot October 17, 2025 07:47
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for querying Azure Subscription Tenant Policies by introducing a new table azure_subscription_tenant_policy. These policies control whether subscriptions can be moved into or out of an Azure tenant, helping organizations maintain subscription governance.

Key Changes:

  • Adds a new Steampipe table for querying tenant-level subscription policies
  • Implements API integration using direct HTTP requests to the Azure Management API
  • Provides comprehensive documentation with example queries

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
azure/table_azure_subscription_tenant_policy.go Implements the new table with API client, column definitions, and response structs
azure/plugin.go Registers the new table in the plugin's table map
docs/tables/azure_subscription_tenant_policy.md Provides documentation and SQL query examples for the new table

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

}

// Send the request
client := &http.Client{}
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating a new HTTP client for each request is inefficient. Consider reusing a shared HTTP client instance or using the session's existing HTTP client infrastructure to improve performance and connection pooling.

Copilot uses AI. Check for mistakes.
Comment on lines 127 to 128
plugin.Logger(ctx).Error("azure_subscription_tenant_policy.listSubscriptionTenantPolicy", "status_code", resp.StatusCode)
return nil, fmt.Errorf("API request failed with status code: %d", resp.StatusCode)
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message should include the response body to help diagnose API failures. Azure API errors typically return JSON with error details that would be valuable for troubleshooting. Consider reading and including the response body in the error message when the status code indicates failure.

Suggested change
plugin.Logger(ctx).Error("azure_subscription_tenant_policy.listSubscriptionTenantPolicy", "status_code", resp.StatusCode)
return nil, fmt.Errorf("API request failed with status code: %d", resp.StatusCode)
body, readErr := io.ReadAll(resp.Body)
if readErr != nil {
plugin.Logger(ctx).Error("azure_subscription_tenant_policy.listSubscriptionTenantPolicy", "status_code", resp.StatusCode, "body_read_error", readErr)
return nil, fmt.Errorf("API request failed with status code: %d (error reading response body: %v)", resp.StatusCode, readErr)
}
plugin.Logger(ctx).Error("azure_subscription_tenant_policy.listSubscriptionTenantPolicy", "status_code", resp.StatusCode, "response_body", string(body))
return nil, fmt.Errorf("API request failed with status code: %d, response body: %s", resp.StatusCode, string(body))

Copilot uses AI. Check for mistakes.
@khushboo9024 khushboo9024 changed the title Add table azure_subscription_policy close #956 Add table azure_subscription_tenant_policy close #956 Oct 17, 2025
@khushboo9024 khushboo9024 changed the title Add table azure_subscription_tenant_policy close #956 Add default_tenant_policy column in table azure_subscription close #956 Oct 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add default_tenant_policy column in table azure_subscription

2 participants