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

Last round of triple slash, I believe. #661

Merged
merged 4 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
;
; Here are some resources for what's supported for .NET/C#
; https://kent-boogaart.com/blog/editorconfig-reference-for-c-developers
; https://learn.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
; https://learn.microsoft.com/visualstudio/ide/editorconfig-code-style-settings-reference
;
; Be **careful** editing this because some of the rules don't support adding a severity level
; For instance if you change to `dotnet_sort_system_directives_first = true:warning` (adding `:warning`)
Expand Down
2 changes: 1 addition & 1 deletion eng/common/templates/job/job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
- name: EnableRichCodeNavigation
value: 'true'
# Retry signature validation up to three times, waiting 2 seconds between attempts.
# See https://learn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu3028#retry-untrusted-root-failures
# See https://learn.microsoft.com/nuget/reference/errors-and-warnings/nu3028#retry-untrusted-root-failures
- name: NUGET_EXPERIMENTAL_CHAIN_BUILD_RETRY_POLICY
value: 3,2000
- ${{ each variable in parameters.variables }}:
Expand Down
2 changes: 1 addition & 1 deletion samples/eShopLite/BasketService/Protos/basket.proto
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ message DeleteCustomerBasketRequest {
message DeleteCustomerBasketResponse {
}

// See: https://learn.microsoft.com/en-us/dotnet/architecture/grpc-for-wcf-developers/protobuf-data-types#decimals
// See: https://learn.microsoft.com/dotnet/architecture/grpc-for-wcf-developers/protobuf-data-types#decimals
// Example: 12345.6789 -> { units = 12345, nanos = 678900000 }
message DecimalValue {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public async ValueTask DisposeAsync()
}
catch (JSDisconnectedException)
{
// Per https://learn.microsoft.com/en-us/aspnet/core/blazor/javascript-interoperability/?view=aspnetcore-7.0#javascript-interop-calls-without-a-circuit
// Per https://learn.microsoft.com/aspnet/core/blazor/javascript-interoperability/?view=aspnetcore-7.0#javascript-interop-calls-without-a-circuit
// this is one of the calls that will fail if the circuit is disconnected, and we just need to catch the exception so it doesn't pollute the logs
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public async ValueTask DisposeAsync()
}
catch (JSDisconnectedException)
{
// Per https://learn.microsoft.com/en-us/aspnet/core/blazor/javascript-interoperability/?view=aspnetcore-7.0#javascript-interop-calls-without-a-circuit
// Per https://learn.microsoft.com/aspnet/core/blazor/javascript-interoperability/?view=aspnetcore-7.0#javascript-interop-calls-without-a-circuit
// this is one of the calls that will fail if the circuit is disconnected, and we just need to catch the exception so it doesn't pollute the logs
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

namespace Aspire.Hosting;

/// <summary>
/// Provides extension methods for adding support for generating Azure resources dynamically during application startup.
/// </summary>
public static class AzureProvisionerExtensions
{
/// <summary>
Expand All @@ -27,11 +30,11 @@ public static IDistributedApplicationBuilder AddAzureProvisioning(this IDistribu
builder.Services.AddLifecycleHook<AzureProvisioner>();

// Attempt to read azure configuration from configuration
builder.Services.AddOptions<AzureProvisinerOptions>()
builder.Services.AddOptions<AzureProvisionerOptions>()
.BindConfiguration("Azure");

// We're adding 2 because there's no easy way to enumerate all keys and all service types
builder.AddAzureProvisioner<AzureKeyVaultResource, KeyVaultProvisoner>();
builder.AddAzureProvisioner<AzureKeyVaultResource, KeyVaultProvisioner>();
builder.AddResourceEnumerator(resourceGroup => resourceGroup.GetKeyVaults(), resource => resource.Data.Tags);

builder.AddAzureProvisioner<AzureStorageResource, StorageProvisioner>();
Expand All @@ -43,7 +46,7 @@ public static IDistributedApplicationBuilder AddAzureProvisioning(this IDistribu
builder.AddAzureProvisioner<AzureRedisResource, AzureRedisProvisioner>();
builder.AddResourceEnumerator(resourceGroup => resourceGroup.GetAllRedis(), resource => resource.Data.Tags);

builder.AddAzureProvisioner<AzureAppConfigurationResource, AppConfigurationProvisoner>();
builder.AddAzureProvisioner<AzureAppConfigurationResource, AppConfigurationProvisioner>();
builder.AddResourceEnumerator(resourceGroup => resourceGroup.GetAppConfigurationStores(), resource => resource.Data.Tags);
return builder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Aspire.Hosting.Azure.Provisioning;

internal sealed class AzureProvisinerOptions
internal sealed class AzureProvisionerOptions
{
public string? SubscriptionId { get; set; }

Expand Down
1 change: 1 addition & 0 deletions src/Aspire.Hosting.Azure.Provisioning/JsonExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Text.Json.Nodes;

namespace Aspire.Hosting.Azure;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace Aspire.Hosting.Azure.Provisioning;

internal sealed class AppConfigurationProvisoner(ILogger<AppConfigurationProvisoner> logger) : AzureResourceProvisioner<AzureAppConfigurationResource>
internal sealed class AppConfigurationProvisioner(ILogger<AppConfigurationProvisioner> logger) : AzureResourceProvisioner<AzureAppConfigurationResource>
{
public override bool ConfigureResource(IConfiguration configuration, AzureAppConfigurationResource resource)
{
Expand Down Expand Up @@ -72,7 +72,7 @@ public override async Task GetOrCreateResourceAsync(
connectionStrings[resource.Name] = resource.Endpoint;

// App Configuration Data Owner
// https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles#app-configuration-data-owner
// https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#app-configuration-data-owner
var roleDefinitionId = CreateRoleDefinitionId(subscription, "5ae67dd6-50cb-40e7-96ff-dc2bfa4b606b");

await DoRoleAssignmentAsync(armClient, appConfigurationResource.Id, principalId, roleDefinitionId, cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace Aspire.Hosting.Azure;

// Provisions azure resources for development purposes
internal sealed class AzureProvisioner(
IOptions<AzureProvisinerOptions> options,
IOptions<AzureProvisionerOptions> options,
IOptions<PublishingOptions> publishingOptions,
IConfiguration configuration,
IHostEnvironment environment,
Expand All @@ -34,7 +34,7 @@ internal sealed class AzureProvisioner(
{
internal const string AspireResourceNameTag = "aspire-resource-name";

private readonly AzureProvisinerOptions _options = options.Value;
private readonly AzureProvisionerOptions _options = options.Value;

public async Task BeforeStartAsync(DistributedApplicationModel appModel, CancellationToken cancellationToken = default)
{
Expand Down Expand Up @@ -186,21 +186,21 @@ await PopulateExistingAspireResources(
{
usedResources.Add(resource.Name);

var provisoner = serviceProvider.GetKeyedService<IAzureResourceProvisioner>(resource.GetType());
var provisioner = serviceProvider.GetKeyedService<IAzureResourceProvisioner>(resource.GetType());

if (provisoner is null)
if (provisioner is null)
{
logger.LogWarning("No provisioner found for {resourceType} skipping.", resource.GetType().Name);
continue;
}

if (!provisoner.ShouldProvision(configuration, resource))
if (!provisioner.ShouldProvision(configuration, resource))
{
logger.LogInformation("Skipping {resourceName} because it is not configured to be provisioned.", resource.Name);
continue;
}

if (provisoner.ConfigureResource(configuration, resource))
if (provisioner.ConfigureResource(configuration, resource))
{
logger.LogInformation("Using connection information stored in user secrets for {resourceName}.", resource.Name);

Expand All @@ -217,7 +217,7 @@ await PopulateExistingAspireResources(
resourceMap ??= await resourceMapLazy.Value.ConfigureAwait(false);
principalId ??= await principalIdLazy.Value.ConfigureAwait(false);

var task = provisoner.GetOrCreateResourceAsync(armClient,
var task = provisioner.GetOrCreateResourceAsync(armClient,
subscription,
resourceGroup,
resourceMap,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Aspire.Hosting.Azure.Provisioning;

internal sealed class KeyVaultProvisoner(ILogger<KeyVaultProvisoner> logger) : AzureResourceProvisioner<AzureKeyVaultResource>
internal sealed class KeyVaultProvisioner(ILogger<KeyVaultProvisioner> logger) : AzureResourceProvisioner<AzureKeyVaultResource>
{
public override bool ConfigureResource(IConfiguration configuration, AzureKeyVaultResource resource)
{
Expand Down Expand Up @@ -76,7 +76,7 @@ public override async Task GetOrCreateResourceAsync(
connectionStrings[keyVault.Name] = keyVault.VaultUri.ToString();

// Key Vault Administrator
// https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles#key-vault-administrator
// https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#key-vault-administrator
var roleDefinitionId = CreateRoleDefinitionId(subscription, "00482a5a-887f-4fb3-b363-3b7fe8e74483");

await DoRoleAssignmentAsync(armClient, keyVaultResource.Id, principalId, roleDefinitionId, cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public override async Task GetOrCreateResourceAsync(
}

// Azure Service Bus Data Owner
// https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles#azure-service-bus-data-owner
// https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#azure-service-bus-data-owner
var roleDefinitionId = CreateRoleDefinitionId(subscription, "090c5cfd-751d-490a-894a-3ce6f1109419");

await DoRoleAssignmentAsync(armClient, serviceBusNamespace.Id, principalId, roleDefinitionId, cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ public override async Task GetOrCreateResourceAsync(
resourceEntry["QueueUri"] = resource.QueueUri.ToString();

// Storage Queue Data Contributor
// https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles#storage-queue-data-contributor
// https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#storage-queue-data-contributor
var storageQueueDataContributorId = CreateRoleDefinitionId(subscription, "974c5e8b-45b9-4653-ba55-5f855dd0fb88");

// Storage Table Data Contributor
// https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles#storage-table-data-contributor
// https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#storage-table-data-contributor
var storageDataContributorId = CreateRoleDefinitionId(subscription, "0a9a7e1f-b9d0-4cc4-a60d-0319b160aaa3");

// Storage Blob Data Contributor
// https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles#storage-blob-data-contributor
// https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#storage-blob-data-contributor
var storageBlobDataContributorId = CreateRoleDefinitionId(subscription, "81a9662b-bebf-436f-a333-f67b29880f12");

var t0 = DoRoleAssignmentAsync(armClient, storageAccount.Id, principalId, storageQueueDataContributorId, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ namespace Aspire.Hosting.Azure;

// Copied from https://github.com/dotnet/runtime/blob/213833ea99b79a4b494b2935e1ccb10b93cd4cbc/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/src/PathHelper.cs

public class UserSecretsPathHelper
/// <summary>
/// Provides helper methods for working with user secrets in a location outside of source control.
/// </summary>
internal sealed class UserSecretsPathHelper
{
internal const string SecretsFileName = "secrets.json";

Expand Down
11 changes: 11 additions & 0 deletions src/Aspire.Hosting.Azure/AzureAppConfigurationResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,20 @@

namespace Aspire.Hosting.ApplicationModel;

/// <summary>
/// Represents an Azure App Configuration resource.
/// </summary>
/// <param name="name">The name of the resource.</param>
public class AzureAppConfigurationResource(string name) : Resource(name), IAzureResource, IResourceWithConnectionString
{
/// <summary>
/// Gets or sets the endpoint for the Azure App Configuration resource.
/// </summary>
public string? Endpoint { get; set; }

/// <summary>
/// Gets the connection string for the Azure App Configuration resource.
/// </summary>
/// <returns>The connection string for the Azure App Configuration resource.</returns>
public string? GetConnectionString() => Endpoint;
}
26 changes: 26 additions & 0 deletions src/Aspire.Hosting.Azure/AzureBlobStorageResource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Aspire.Hosting.ApplicationModel;

/// <summary>
/// Represents a resource that is stored in Azure Blob Storage.
/// </summary>
/// <param name="name">The name of the resource.</param>
/// <param name="storage">The <see cref="AzureStorageResource"/> that the resource is stored in.</param>
public class AzureBlobStorageResource(string name, AzureStorageResource storage) : Resource(name),
IAzureResource,
IResourceWithConnectionString,
IResourceWithParent<AzureStorageResource>
{
/// <summary>
/// Gets the parent AzureStorageResource of this AzureBlobStorageResource.
/// </summary>
public AzureStorageResource Parent => storage;

/// <summary>
/// Gets the connection string for the Azure Blob Storage resource.
/// </summary>
/// <returns>The connection string for the Azure Blob Storage resource.</returns>
public string? GetConnectionString() => Parent.GetBlobConnectionString();
}
11 changes: 11 additions & 0 deletions src/Aspire.Hosting.Azure/AzureKeyVaultResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,20 @@

namespace Aspire.Hosting.ApplicationModel;

/// <summary>
/// Represents an Azure Key Vault resource that can be deployed to an Azure resource group.
/// </summary>
/// <param name="name">The name of the resource.</param>
public class AzureKeyVaultResource(string name) : Resource(name), IAzureResource, IResourceWithConnectionString
{
/// <summary>
/// Gets or sets the URI of the Azure Key Vault.
/// </summary>
public Uri? VaultUri { get; set; }

/// <summary>
/// Gets the connection string for the Azure Key Vault resource.
/// </summary>
/// <returns>The connection string for the Azure Key Vault resource.</returns>
public string? GetConnectionString() => VaultUri?.ToString();
}
26 changes: 26 additions & 0 deletions src/Aspire.Hosting.Azure/AzureQueueStorageResource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Aspire.Hosting.ApplicationModel;

/// <summary>
/// Represents an Azure Queue Storage resource.
/// </summary>
/// <param name="name">The name of the resource.</param>
/// <param name="storage">The <see cref="AzureStorageResource"/> that the resource is stored in.</param>
public class AzureQueueStorageResource(string name, AzureStorageResource storage) : Resource(name),
IAzureResource,
IResourceWithConnectionString,
IResourceWithParent<AzureStorageResource>
{
/// <summary>
/// Gets the parent AzureStorageResource of this AzureQueueStorageResource.
/// </summary>
public AzureStorageResource Parent => storage;

/// <summary>
/// Gets the connection string for the Azure Queue Storage resource.
/// </summary>
/// <returns>The connection string for the Azure Queue Storage resource.</returns>
public string? GetConnectionString() => Parent.GetQueueConnectionString();
}
11 changes: 11 additions & 0 deletions src/Aspire.Hosting.Azure/AzureRedisResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,20 @@

namespace Aspire.Hosting.ApplicationModel;

/// <summary>
/// Represents an Azure Redis resource.
/// </summary>
/// <param name="name">The name of the resource.</param>
public class AzureRedisResource(string name) : Resource(name), IAzureResource, IResourceWithConnectionString
{
/// <summary>
/// Gets or sets the connection string for the Azure Redis resource.
/// </summary>
public string? ConnectionString { get; set; }

/// <summary>
/// Gets the connection string for the Azure Redis resource.
/// </summary>
/// <returns>The connection string for the Azure Redis resource.</returns>
public string? GetConnectionString() => ConnectionString;
}
3 changes: 3 additions & 0 deletions src/Aspire.Hosting.Azure/AzureResourceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

namespace Aspire.Hosting;

/// <summary>
/// Provides extension methods for adding Azure resources to the application model.
/// </summary>
public static class AzureResourceExtensions
{
/// <summary>
Expand Down
20 changes: 19 additions & 1 deletion src/Aspire.Hosting.Azure/AzureServiceBusResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,31 @@

namespace Aspire.Hosting.ApplicationModel;

/// <summary>
/// Represents an Azure Service Bus resource.
/// </summary>
/// <param name="name">The name of the resource.</param>
public class AzureServiceBusResource(string name) : Resource(name), IAzureResource, IResourceWithConnectionString
{
// This is the full uri to the service bus namespace e.g namespace.servicebus.windows.net
/// <summary>
/// Gets or sets the Service Bus endpoint. This is the full uri to the service bus
/// namespace, for example <c>"namespace.servicebus.windows.net"</c>.
/// </summary>
public string? ServiceBusEndpoint { get; set; }

/// <summary>
/// Gets or sets the names of the queues associated with the Azure Service Bus resource.
/// </summary>
public string[] QueueNames { get; set; } = [];

/// <summary>
/// Gets or sets the names of the topics associated with the Azure Service Bus resource.
/// </summary>
public string[] TopicNames { get; set; } = [];

/// <summary>
/// Gets the connection string for the Azure Service Bus endpoint.
/// </summary>
/// <returns>The connection string for the Azure Service Bus endpoint.</returns>
public string? GetConnectionString() => ServiceBusEndpoint;
}
Loading