Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add column diagnostic_logs_configuration to table azure_app_service_web_app Closes #516 #517

Merged
merged 1 commit into from
Sep 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion azure/table_azure_app_service_web_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ func tableAzureAppServiceWebApp(_ context.Context) *plugin.Table {
Hydrate: getAppServiceWebAppSiteConfiguration,
Transform: transform.FromValue(),
},
{
Name: "diagnostic_logs_configuration",
Description: "Describes the logging configuration of an app.",
Type: proto.ColumnType_JSON,
Hydrate: getWebAppDiagnosticLogsConfiguration,
Transform: transform.FromValue(),
},
{
Name: "site_config",
Description: "A map of all configuration for the app.",
Expand Down Expand Up @@ -325,7 +332,7 @@ func getAppServiceWebAppVnetConnection(ctx context.Context, d *plugin.QueryData,
plugin.Logger(ctx).Trace("getAppServiceWebAppVnetConnection")

data := h.Item.(web.Site)

// Web App Site Configuration will be nil if getAppServiceWebAppSiteConfiguration returned an error but
// was ignored through ignore_error_codes config arg
if h.HydrateResults["getAppServiceWebAppSiteConfiguration"] == nil {
Expand Down Expand Up @@ -371,6 +378,28 @@ func getAppServiceWebAppVnetConnection(ctx context.Context, d *plugin.QueryData,
return nil, nil
}

func getWebAppDiagnosticLogsConfiguration(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) {
data := h.Item.(web.Site)

session, err := GetNewSession(ctx, d, "MANAGEMENT")
if err != nil {
plugin.Logger(ctx).Error("azure_app_service_web_app.getWebAppDiagnosticLogsConfiguration", "service_creation_error", err)
return nil, err
}
subscriptionID := session.SubscriptionID

webClient := web.NewAppsClientWithBaseURI(session.ResourceManagerEndpoint, subscriptionID)
webClient.Authorizer = session.Authorizer

op, err := webClient.GetDiagnosticLogsConfiguration(ctx, *data.SiteProperties.ResourceGroup, *data.Name)
if err != nil {
plugin.Logger(ctx).Error("azure_app_service_web_app.getWebAppDiagnosticLogsConfiguration", "api_error", err)
return nil, err
}

return op, nil
}

//// TRANSFORM FUNCTION

func webAppIdentity(ctx context.Context, d *transform.TransformData) (interface{}, error) {
Expand Down