ASPIREUSERSECRETS001
यह कंटेंट अभी तक आपकी भाषा में उपलब्ध नहीं है।
Type is for evaluation purposes only and is subject to change or removal in future updates
This diagnostic warns when using the experimental IUserSecretsManager interface and related user secrets management APIs. These APIs provide centralized management of user secrets for Aspire applications, enabling secure storage and retrieval of sensitive configuration values.
Example generating diagnostic
Section titled “Example generating diagnostic”var builder = DistributedApplication.CreateBuilder(args);
// Using IUserSecretsManagervar userSecretsManager = builder.UserSecretsManager;var filePath = userSecretsManager.FilePath;bool success = userSecretsManager.TrySetSecret("MySecret", "SecretValue");The diagnostic is triggered because IUserSecretsManager is marked with the [Experimental("ASPIREUSERSECRETS001")] attribute.
Understanding the diagnostic
Section titled “Understanding the diagnostic”The IUserSecretsManager interface provides user secrets management functionality for Aspire:
- Secret storage: Save sensitive values like API keys and passwords outside source control
- Secret retrieval: Read secrets from the user secrets file
- Configuration integration: Automatically populate configuration from secrets
- State management: Support for saving deployment state to user secrets
This API is experimental because the user secrets management strategy is being refined based on security requirements and usage patterns, and the interface may evolve to support additional secret management scenarios.
Related types
Section titled “Related types”IUserSecretsManager: Interface for managing user secretsUserSecretsManager: Default implementation managing secrets file operationsUserSecretsManagerFactory: Factory for creating and caching manager instancesFilePath: Gets the path to the user secrets JSON fileTrySetSecret(): Attempts to set a secret value in user secretsGetOrSetSecret(): Gets a secret from configuration or generates and saves a new valueSaveStateAsync(): Saves deployment state to user secrets asynchronously
Suppressing the diagnostic
Section titled “Suppressing the diagnostic”The diagnostic can be suppressed using one of several methods:
Suppressing in .editorconfig
Section titled “Suppressing in .editorconfig”[*.cs]dotnet_diagnostic.ASPIREUSERSECRETS001.severity = noneSuppressing in a project file
Section titled “Suppressing in a project file”<PropertyGroup> <NoWarn>$(NoWarn);ASPIREUSERSECRETS001</NoWarn></PropertyGroup>Suppressing in source code
Section titled “Suppressing in source code”#pragma warning disable ASPIREUSERSECRETS001var userSecretsManager = builder.UserSecretsManager;bool success = userSecretsManager.TrySetSecret("MySecret", "SecretValue");#pragma warning restore ASPIREUSERSECRETS001