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

Configuration Schema generator #1383

Merged
merged 21 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from 17 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
9 changes: 9 additions & 0 deletions Aspire.sln
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspire.MySqlConnector.Tests
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestProject.IntegrationServiceA", "tests\testproject\TestProject.IntegrationServiceA\TestProject.IntegrationServiceA.csproj", "{DCF2D47A-921A-4900-B5B2-CF97B3531CE8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{2136E31D-2CBB-41BB-8618-716FF8E46E9E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConfigurationSchemaGenerator", "src\Tools\ConfigurationSchemaGenerator\ConfigurationSchemaGenerator.csproj", "{39FA2A64-012F-4EB9-A14F-E8AC54C975F6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.MongoDB.Driver", "src\Components\Aspire.MongoDB.Driver\Aspire.MongoDB.Driver.csproj", "{20A5A907-A135-4735-B4BF-E13514F360E3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.MongoDB.Driver.Tests", "tests\Aspire.MongoDB.Driver.Tests\Aspire.MongoDB.Driver.Tests.csproj", "{E592E447-BA3C-44FA-86C1-EBEDC864A644}"
Expand Down Expand Up @@ -447,6 +451,10 @@ Global
{6472D59F-7C04-43DE-AD33-9F20BE3804BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6472D59F-7C04-43DE-AD33-9F20BE3804BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6472D59F-7C04-43DE-AD33-9F20BE3804BF}.Release|Any CPU.Build.0 = Release|Any CPU
{39FA2A64-012F-4EB9-A14F-E8AC54C975F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{39FA2A64-012F-4EB9-A14F-E8AC54C975F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{39FA2A64-012F-4EB9-A14F-E8AC54C975F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{39FA2A64-012F-4EB9-A14F-E8AC54C975F6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -524,6 +532,7 @@ Global
{20A5A907-A135-4735-B4BF-E13514F360E3} = {27381127-6C45-4B4C-8F18-41FF48DFE4B2}
{E592E447-BA3C-44FA-86C1-EBEDC864A644} = {4981B3A5-4AFD-4191-BF7D-8692D9783D60}
{DCF2D47A-921A-4900-B5B2-CF97B3531CE8} = {975F6F41-B455-451D-A312-098DE4A167B6}
{39FA2A64-012F-4EB9-A14F-E8AC54C975F6} = {2136E31D-2CBB-41BB-8618-716FF8E46E9E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6DCEDFEC-988E-4CB3-B45B-191EB5086E0C}
Expand Down
3 changes: 3 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
<PackageVersion Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="$(MicrosoftExtensionsDiagnosticsHealthChecksEntityFrameworkCorePackageVersion)" />
<PackageVersion Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="$(MicrosoftExtensionsDiagnosticsHealthChecksPackageVersion)" />
<PackageVersion Include="Microsoft.Extensions.Features" Version="$(MicrosoftExtensionsFeaturesPackageVersion)" />
<!-- Roslyn dependencies -->
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" />
joperezr marked this conversation as resolved.
Show resolved Hide resolved
<!-- AspNetCore.HealthChecks dependencies (3rd party packages) -->
<PackageVersion Include="AspNetCore.HealthChecks.Azure.Data.Tables" Version="7.0.0" />
<PackageVersion Include="AspNetCore.HealthChecks.Azure.KeyVault.Secrets" Version="7.0.0-rc1.1" />
Expand Down Expand Up @@ -82,6 +84,7 @@
<PackageVersion Include="StackExchange.Redis" Version="2.7.4" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageVersion Include="Yarp.ReverseProxy" Version="2.1.0" />
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.23407.1" />
<!-- Open Telemetry -->
<PackageVersion Include="Npgsql.OpenTelemetry" Version="8.0.0" />
<PackageVersion Include="OpenTelemetry.Exporter.InMemory" Version="1.7.0-alpha.1" />
Expand Down
1 change: 1 addition & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</packageSource>
<packageSource key="dotnet-libraries">
<package pattern="Microsoft.DeveloperControlPlane*" />
<package pattern="System.CommandLine" />
</packageSource>
<packageSource key="dotnet-eng">
<package pattern="*" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

<ItemGroup>
<Compile Include="..\Common\AzureComponent.cs" Link="AzureComponent.cs" />
<Compile Include="..\Common\ConfigurationSchemaAttribute.cs" Link="ConfigurationSchemaAttribute.cs" />
<Compile Include="..\Common\HealthChecksExtensions.cs" Link="HealthChecksExtensions.cs" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Aspire;
using Aspire.Azure.Common;
using Aspire.Azure.Storage.Blobs;
using Azure.Core;
Expand All @@ -12,6 +13,15 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;

[assembly: ConfigurationSchema(
eerhardt marked this conversation as resolved.
Show resolved Hide resolved
Types = [typeof(AzureStorageBlobsSettings), typeof(BlobClientOptions)],
ConfigurationPaths = ["Aspire:Azure:Storage:Blobs", "Aspire:Azure:Storage:Blobs:ClientOptions"],
ExclusionPaths = ["Aspire:Azure:Storage:Blobs:ClientOptions:Default"],
LogCategories = [
"Azure",
"Azure.Core",
"Azure.Identity"])]

namespace Microsoft.Extensions.Hosting;

/// <summary>
Expand Down
137 changes: 109 additions & 28 deletions src/Components/Aspire.Azure.Storage.Blobs/ConfigurationSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,75 +27,156 @@
"Blobs": {
"type": "object",
"properties": {
"ServiceUri": {
"type": "string",
"format": "uri",
"description": "Gets or sets the 'Uri' referencing the Blob service. This is likely to be similar to \"https://{account_name}.blob.core.windows.net\""
},
"HealthChecks": {
"type": "boolean",
"description": "Gets or sets a boolean value that indicates whether the Blob Storage health check is enabled or not.",
"default": true
},
"Tracing": {
"type": "boolean",
"description": "Gets or sets a boolean value that indicates whether the OpenTelemetry tracing is enabled or not.",
"default": false
},
"ClientOptions": {
"type": "object",
"description": "Provides the client configuration options for connecting to Azure Blob Storage.",
"properties": {
"Diagnostics": {
"type": "object",
"properties": {
"ApplicationId": {
"type": "string",
"description": "Gets or sets the value sent as the first part of \u0022User-Agent\u0022 headers for all requests issues by this client. Defaults to P:Azure.Core.DiagnosticsOptions.DefaultApplicationId."
},
"DefaultApplicationId": {
"type": "string",
"description": "Gets or sets the default application id. Default application id would be set on all instances."
},
"IsDistributedTracingEnabled": {
"type": "boolean",
"description": "Gets or sets value indicating whether distributed tracing activities ( T:System.Diagnostics.Activity ) are going to be created for the clients methods calls and HTTP calls."
},
"IsLoggingContentEnabled": {
"type": "boolean",
"description": "Gets or sets value indicating if request or response content should be logged."
},
"IsLoggingEnabled": {
"type": "boolean",
"description": "Get or sets value indicating whether HTTP pipeline logging is enabled."
},
"IsTelemetryEnabled": {
"type": "boolean",
"description": "Gets or sets value indicating whether the \u0022User-Agent\u0022 header containing P:Azure.Core.DiagnosticsOptions.ApplicationId , client library package name and version, P:System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription and P:System.Runtime.InteropServices.RuntimeInformation.OSDescription should be sent.\r\n The default value can be controlled process wide by setting AZURE_TELEMETRY_DISABLED to true , false , 1 or 0."
},
"LoggedContentSizeLimit": {
"type": "integer",
"description": "Gets or sets value indicating maximum size of content to log in bytes. Defaults to 4096."
}
},
"description": "Gets the client diagnostic options."
},
"EnableTenantDiscovery": {
"type": "boolean",
"description": "Enables tenant discovery through the authorization challenge when the client is configured to use a TokenCredential. When enabled, the client will attempt an initial un-authorized request to prompt a challenge in order to discover the correct tenant for the resource."
"description": "Enables tenant discovery through the authorization challenge when the client is configured to use a TokenCredential.\r\n When enabled, the client will attempt an initial un-authorized request to prompt a challenge in order to discover the correct tenant for the resource."
},
"EncryptionScope": {
"type": "string",
"description": "Gets the EncryptionScope to be used when making requests."
"description": "Gets the P:Azure.Storage.Blobs.BlobClientOptions.EncryptionScope to be used when making requests."
},
"GeoRedundantSecondaryUri": {
"type": "string",
"format": "uri",
"description": "Gets or sets the secondary storage Uri that can be read from for the storage account if the account is enabled for RA-GRS."
"description": "Gets or sets the secondary storage T:System.Uri that can be read from for the storage account if the\r\n account is enabled for RA-GRS.\r\n \r\n If this property is set, the secondary Uri will be used for GET or HEAD requests during retries.\r\n If the status of the response from the secondary Uri is a 404, then subsequent retries for\r\n the request will not use the secondary Uri again, as this indicates that the resource\r\n may not have propagated there yet. Otherwise, subsequent retries will alternate back and forth\r\n between primary and secondary Uri."
Copy link
Member

Choose a reason for hiding this comment

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

Interesting, I'm curious, how does this render in the IDE, I suppose it actually shows the new lines as opposed to having the new line characters printed out?

Copy link
Member Author

Choose a reason for hiding this comment

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

It renders the newlines correctly. This is an area that will probably need to be tweaked over time. I don't know why the newlines and extra spaces are in there. I need to look at some more Roslyn code to figure out how they strip out all the whitespace in these XML docs.

image

},
"Retry": {
"type": "object",
"description": "The set of options that can be specified to influence how retry attempts are made, and a failure is eligible to be retried",
"properties": {
"Delay": {
"type": "string",
"format": "duration",
"description": "The delay between retry attempts for a fixed approach or the delay on which to base calculations for a backoff-based approach. If the service provides a Retry-After response header, the next retry will be delayed by the duration specified by the header value."
"description": "The delay between retry attempts for a fixed approach or the delay\r\n on which to base calculations for a backoff-based approach.\r\n If the service provides a Retry-After response header, the next retry will be delayed by the duration specified by the header value."
},
"MaxDelay": {
"type": "string",
"format": "duration",
"description": "The maximum permissible delay between retry attempts when the service does not provide a Retry-After response header. If the service provides a Retry-After response header, the next retry will be delayed by the duration specified by the header value."
"description": "The maximum permissible delay between retry attempts when the service does not provide a Retry-After response header.\r\n If the service provides a Retry-After response header, the next retry will be delayed by the duration specified by the header value."
},
"MaxRetries": {
"type": "integer",
"description": "The maximum number of retry attempts before giving up."
},
"Mode": {
"enum": [ "Fixed", "Exponential" ],
"enum": [
"Fixed",
"Exponential"
],
"description": "The approach to use for calculating retry delays."
},
"NetworkTimeout": {
"type": "string",
"format": "duration",
"description": "The timeout applied to an individual network operations."
}
}
},
"description": "Gets the client retry options."
},
"TransferValidation": {
"type": "object",
"properties": {
"Download": {
"type": "object",
"properties": {
"AutoValidateChecksum": {
"type": "boolean",
"description": "Defaults to true. False can only be specified on specific operations and not at the client level.\r\n Indicates whether the SDK should validate the content\r\n body against the content hash before returning contents to the caller.\r\n If set to false, caller is responsible for extracting the hash out\r\n of the T:Azure.Response\u00601 and validating the hash themselves."
},
"ChecksumAlgorithm": {
"enum": [
"Auto",
"None",
"MD5",
"StorageCrc64"
],
"description": "Checksum algorithm to use."
}
},
"description": "Options on download."
},
"Upload": {
"type": "object",
"properties": {
"ChecksumAlgorithm": {
"enum": [
"Auto",
"None",
"MD5",
"StorageCrc64"
],
"description": "Checksum algorithm to use."
}
},
"description": "Options on upload."
}
},
"description": "Configures whether to send or receive checksum headers for blob uploads and downloads. Downloads\r\n can optionally validate that the content matches the checksum."
},
"TrimBlobNameSlashes": {
"type": "boolean",
"description": "Whether to trim leading and trailing slashes on a blob name when using GetBlobClient(String) and similar methods.",
"default": true
"description": "Whether to trim leading and trailing slashes on a blob name when using M:Azure.Storage.Blobs.BlobContainerClient.GetBlobClient(System.String) and similar methods.\r\n Defaults to true for backwards compatibility."
}
}
},
"description": "Provides the client configuration options for connecting to Azure Blob\r\n Storage."
},
"ConnectionString": {
"type": "string",
"description": "Gets or sets the connection string used to connect to the blob service."
},
"HealthChecks": {
"type": "boolean",
"description": "Gets or sets a boolean value that indicates whether the Blob Storage health check is enabled or not.",
"default": true
},
"ServiceUri": {
"type": "string",
"format": "uri",
"description": "A T:System.Uri referencing the blob service.\r\n This is likely to be similar to \u0022https://{account_name}.blob.core.windows.net\u0022."
},
"Tracing": {
"type": "boolean",
"description": "Gets or sets a boolean value that indicates whether the OpenTelemetry tracing is enabled or not.",
"default": true
}
}
},
"description": "Provides the client configuration settings for connecting to Azure Blob Storage."
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<ItemGroup>
<Compile Include="..\Common\HealthChecksExtensions.cs" Link="HealthChecksExtensions.cs" />
<Compile Include="..\Common\ConfigurationSchemaAttribute.cs" Link="ConfigurationSchemaAttribute.cs" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@
using Microsoft.Extensions.Logging;
using MySqlConnector;

[assembly: ConfigurationSchema(
Types = [typeof(MySqlConnectorSettings)],
ConfigurationPaths = ["Aspire:MySqlConnector"],
LogCategories = [
"MySqlConnector",
"MySqlConnector.ConnectionPool",
"MySqlConnector.MySqlBulkCopy",
"MySqlConnector.MySqlCommand",
"MySqlConnector.MySqlConnection",
"MySqlConnector.MySqlDataSource"])]

namespace Microsoft.Extensions.Hosting;

/// <summary>
Expand Down
Loading
Loading