Skip to content
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
5 changes: 5 additions & 0 deletions Aspire.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
<Project Path="src/Aspire.Hosting.Azure.Functions/Aspire.Hosting.Azure.Functions.csproj" />
<Project Path="src/Aspire.Hosting.Azure.KeyVault/Aspire.Hosting.Azure.KeyVault.csproj" />
<Project Path="src/Aspire.Hosting.Azure.Kusto/Aspire.Hosting.Azure.Kusto.csproj" />
<Project Path="src/Aspire.Hosting.Azure.Network/Aspire.Hosting.Azure.Network.csproj" />
<Project Path="src/Aspire.Hosting.Azure.OperationalInsights/Aspire.Hosting.Azure.OperationalInsights.csproj" />
<Project Path="src/Aspire.Hosting.Azure.PostgreSQL/Aspire.Hosting.Azure.PostgreSQL.csproj" />
<Project Path="src/Aspire.Hosting.Azure.Redis/Aspire.Hosting.Azure.Redis.csproj" />
Expand Down Expand Up @@ -159,6 +160,10 @@
<Project Path="playground/AzureStorageEndToEnd/AzureStorageEndToEnd.ApiService/AzureStorageEndToEnd.ApiService.csproj" />
<Project Path="playground/AzureStorageEndToEnd/AzureStorageEndToEnd.AppHost/AzureStorageEndToEnd.AppHost.csproj" />
</Folder>
<Folder Name="/playground/AzureVirtualNetworkEndToEnd/">
<Project Path="playground/AzureVirtualNetworkEndToEnd/AzureVirtualNetworkEndToEnd.ApiService/AzureVirtualNetworkEndToEnd.ApiService.csproj" />
<Project Path="playground/AzureVirtualNetworkEndToEnd/AzureVirtualNetworkEndToEnd.AppHost/AzureVirtualNetworkEndToEnd.AppHost.csproj" />
</Folder>
<Folder Name="/playground/bicep/">
<Project Path="playground/bicep/BicepSample.ApiService/BicepSample.ApiService.csproj" />
<Project Path="playground/bicep/BicepSample.AppHost/BicepSample.AppHost.csproj" />
Expand Down
2 changes: 2 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@
<PackageVersion Include="Azure.Provisioning.EventHubs" Version="1.1.0" />
<PackageVersion Include="Azure.Provisioning.KeyVault" Version="1.1.0" />
<PackageVersion Include="Azure.Provisioning.Kusto" Version="1.0.0-beta.1" />
<PackageVersion Include="Azure.Provisioning.Network" Version="1.0.0-beta.3" />
<PackageVersion Include="Azure.Provisioning.OperationalInsights" Version="1.1.0" />
<PackageVersion Include="Azure.Provisioning.PostgreSql" Version="1.1.1" />
<PackageVersion Include="Azure.Provisioning.PrivateDns" Version="1.0.0-beta.1" />
<PackageVersion Include="Azure.Provisioning.Redis" Version="1.1.0" />
<PackageVersion Include="Azure.Provisioning.RedisEnterprise" Version="1.1.0" />
<PackageVersion Include="Azure.Provisioning.Search" Version="1.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ resource storage 'Microsoft.Storage/storageAccounts@2024-01-01' = {
properties: {
accessTier: 'Hot'
allowSharedKeyAccess: false
isHnsEnabled: false
minimumTlsVersion: 'TLS1_2'
networkAcls: {
defaultAction: 'Allow'
Expand Down Expand Up @@ -48,8 +49,12 @@ resource myqueue 'Microsoft.Storage/storageAccounts/queueServices/queues@2024-01

output blobEndpoint string = storage.properties.primaryEndpoints.blob

output dataLakeEndpoint string = storage.properties.primaryEndpoints.dfs

output queueEndpoint string = storage.properties.primaryEndpoints.queue

output tableEndpoint string = storage.properties.primaryEndpoints.table

output name string = storage.name
output name string = storage.name

output id string = storage.id
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ resource storage2 'Microsoft.Storage/storageAccounts@2024-01-01' = {
properties: {
accessTier: 'Hot'
allowSharedKeyAccess: false
isHnsEnabled: false
minimumTlsVersion: 'TLS1_2'
networkAcls: {
defaultAction: 'Allow'
Expand All @@ -33,8 +34,12 @@ resource foocontainer 'Microsoft.Storage/storageAccounts/blobServices/containers

output blobEndpoint string = storage2.properties.primaryEndpoints.blob

output dataLakeEndpoint string = storage2.properties.primaryEndpoints.dfs

output queueEndpoint string = storage2.properties.primaryEndpoints.queue

output tableEndpoint string = storage2.properties.primaryEndpoints.table

output name string = storage2.name
output name string = storage2.name

output id string = storage2.id
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>$(DefaultTargetFramework)</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<AspireProjectOrPackageReference Include="Aspire.Azure.Storage.Blobs" />
<AspireProjectOrPackageReference Include="Aspire.Azure.Storage.Queues" />
<ProjectReference Include="..\..\Playground.ServiceDefaults\Playground.ServiceDefaults.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Azure.Storage.Blobs;
using Azure.Storage.Queues;

var builder = WebApplication.CreateBuilder(args);

builder.AddServiceDefaults();

builder.AddAzureBlobContainerClient("mycontainer");

builder.AddKeyedAzureQueue("myqueue");

var app = builder.Build();

app.MapDefaultEndpoints();

app.MapGet("/", async (BlobContainerClient containerClient, [FromKeyedServices("myqueue")] QueueClient queue) =>
{
var blobNames = new List<string>();
var blobNameAndContent = Guid.NewGuid().ToString();

await containerClient.UploadBlobAsync(blobNameAndContent, new BinaryData(blobNameAndContent));

await ReadBlobsAsync(containerClient, blobNames);

await queue.SendMessageAsync("Hello, world!");

return blobNames;
});

app.Run();

static async Task ReadBlobsAsync(BlobContainerClient containerClient, List<string> output)
{
output.Add(containerClient.Uri.ToString());
var blobs = containerClient.GetBlobsAsync();
await foreach (var blob in blobs)
{
output.Add(blob.Name);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5193",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>$(DefaultTargetFramework)</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireHost>true</IsAspireHost>
<UserSecretsId>d3e0c7a8-1f5b-4c2d-8e9a-6b7c8d9e0f1a</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<AspireProjectOrPackageReference Include="Aspire.Hosting.Azure" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.Azure.AppContainers" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.Azure.Network" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.Azure.Storage" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.AppHost" />

<ProjectReference Include="..\AzureVirtualNetworkEndToEnd.ApiService\AzureVirtualNetworkEndToEnd.ApiService.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

var builder = DistributedApplication.CreateBuilder(args);

// Create a virtual network with two subnets:
// - One for the Container App Environment (with service delegation)
// - One for private endpoints
var vnet = builder.AddAzureVirtualNetwork("vnet");

var containerAppsSubnet = vnet.AddSubnet("container-apps", "10.0.0.0/23");
var privateEndpointsSubnet = vnet.AddSubnet("private-endpoints", "10.0.2.0/27");

// Configure the Container App Environment to use the VNet
builder.AddAzureContainerAppEnvironment("env")
.WithDelegatedSubnet(containerAppsSubnet);

var storage = builder.AddAzureStorage("storage").RunAsEmulator();

var blobs = storage.AddBlobs("blobs");
var mycontainer = storage.AddBlobContainer("mycontainer");

var queues = storage.AddQueues("queues");
var myqueue = storage.AddQueue("myqueue");

// Add private endpoints for blob and queue storage
// This automatically:
// - Creates Private DNS Zones for each service
// - Links the DNS zones to the VNet
// - Creates the Private Endpoints
// - Locks down public access to the storage account
privateEndpointsSubnet.AddPrivateEndpoint(blobs);
privateEndpointsSubnet.AddPrivateEndpoint(queues);

builder.AddProject<Projects.AzureVirtualNetworkEndToEnd_ApiService>("api")
.WithExternalHttpEndpoints()
.WithReference(mycontainer).WaitFor(mycontainer)
.WithReference(myqueue).WaitFor(myqueue);

builder.Build().Run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:16129;http://localhost:16130",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:17049",
"ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "https://localhost:18026",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:17049",
"ASPIRE_SHOW_DASHBOARD_RESOURCES": "true"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:16130",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:17050",
"ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "http://localhost:18027",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:17050",
"ASPIRE_SHOW_DASHBOARD_RESOURCES": "true",
"ASPIRE_ALLOW_UNSECURED_TRANSPORT": "true"
}
},
"generate-manifest": {
"commandName": "Project",
"launchBrowser": true,
"dotnetRunMessages": true,
"commandLineArgs": "--publisher manifest --output-path aspire-manifest.json",
"applicationUrl": "http://localhost:16130",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:17050"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
@description('The location for the resource(s) to be deployed.')
param location string = resourceGroup().location

param env_outputs_azure_container_apps_environment_default_domain string

param env_outputs_azure_container_apps_environment_id string

param api_containerimage string

param api_identity_outputs_id string

param api_containerport string

param storage_outputs_blobendpoint string

param storage_outputs_queueendpoint string

param api_identity_outputs_clientid string

param env_outputs_azure_container_registry_endpoint string

param env_outputs_azure_container_registry_managed_identity_id string

resource api 'Microsoft.App/containerApps@2025-02-02-preview' = {
name: 'api'
location: location
properties: {
configuration: {
activeRevisionsMode: 'Single'
ingress: {
external: true
targetPort: int(api_containerport)
transport: 'http'
}
registries: [
{
server: env_outputs_azure_container_registry_endpoint
identity: env_outputs_azure_container_registry_managed_identity_id
}
]
runtime: {
dotnet: {
autoConfigureDataProtection: true
}
}
}
environmentId: env_outputs_azure_container_apps_environment_id
template: {
containers: [
{
image: api_containerimage
name: 'api'
env: [
{
name: 'OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY'
value: 'in_memory'
}
{
name: 'ASPNETCORE_FORWARDEDHEADERS_ENABLED'
value: 'true'
}
{
name: 'HTTP_PORTS'
value: api_containerport
}
{
name: 'ConnectionStrings__mycontainer'
value: 'Endpoint=${storage_outputs_blobendpoint};ContainerName=mycontainer'
}
{
name: 'MYCONTAINER_URI'
value: storage_outputs_blobendpoint
}
{
name: 'MYCONTAINER_BLOBCONTAINERNAME'
value: 'mycontainer'
}
{
name: 'ConnectionStrings__myqueue'
value: 'Endpoint=${storage_outputs_queueendpoint};QueueName=myqueue'
}
{
name: 'MYQUEUE_URI'
value: storage_outputs_queueendpoint
}
{
name: 'MYQUEUE_QUEUENAME'
value: 'myqueue'
}
{
name: 'AZURE_CLIENT_ID'
value: api_identity_outputs_clientid
}
{
name: 'AZURE_TOKEN_CREDENTIALS'
value: 'ManagedIdentityCredential'
}
]
}
]
scale: {
minReplicas: 1
}
}
}
identity: {
type: 'UserAssigned'
userAssignedIdentities: {
'${api_identity_outputs_id}': { }
'${env_outputs_azure_container_registry_managed_identity_id}': { }
}
}
}
Loading
Loading