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

Updating samples for preview.2 #55

Merged
merged 14 commits into from
Dec 20, 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
24 changes: 12 additions & 12 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<AspNetCoreVersion>8.0.0</AspNetCoreVersion>
<EfCoreVersion>8.0.0</EfCoreVersion>
<RuntimeVersion>8.0.0</RuntimeVersion>
<GrpcVersion>2.58.0</GrpcVersion>
<AspireVersion>8.0.0-preview.1.23557.2</AspireVersion>
<GrpcVersion>2.59.0</GrpcVersion>
<AspireVersion>8.0.0-preview.2.23619.3</AspireVersion>
</PropertyGroup>
<ItemGroup>
<!-- Version together with Aspire -->
Expand Down Expand Up @@ -48,22 +48,22 @@
<PackageVersion Include="Grpc.Net.Client" Version="$(GrpcVersion)" />
<PackageVersion Include="Grpc.Net.ClientFactory" Version="$(GrpcVersion)" />
<PackageVersion Include="Grpc.Net.Server" Version="$(GrpcVersion)" />
<PackageVersion Include="Grpc.Tools" Version="2.59.0" />
<PackageVersion Include="Grpc.Tools" Version="2.60.0" />
<!-- Open Telemetry -->
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.7.0-alpha.1" />
<PackageVersion Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.7.0-alpha.1" />
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.7.0-alpha.1" />
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.6.0-beta.2" />
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.7.0" />
<PackageVersion Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.7.0-rc.1" />
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.7.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.7.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.EventCounters" Version="1.5.1-alpha.1" />
<PackageVersion Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.6.0-beta.2" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.6.0-beta.2" />
<PackageVersion Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.6.0-beta.3" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.7" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="1.5.1" />
<!-- VS Test -->
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<!-- Miscellaneous -->
<PackageVersion Include="AspNetCore.HealthChecks.Uris" Version="7.0.0" />
<PackageVersion Include="AspNetCore.HealthChecks.Uris" Version="8.0.0" />
<PackageVersion Include="Dapr.AspNetCore" Version="1.12.0" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageVersion Include="Yarp.ReverseProxy" Version="2.1.0-preview.1.23556.5" />
<PackageVersion Include="Yarp.ReverseProxy" Version="2.1.0" />
</ItemGroup>
</Project>
2 changes: 0 additions & 2 deletions samples/AspireWithDapr/AspireWithDapr.AppHost/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
var builder = DistributedApplication.CreateBuilder(args);

builder.AddDapr();

builder.AddProject<Projects.AspireWithDapr_ApiService>("apiservice")
.WithDaprSidecar("api");

Expand Down
2 changes: 2 additions & 0 deletions samples/AspireWithDapr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ This is a simple .NET app that shows how to use Dapr with .NET Aspire orchestrat

## Sample prerequisites

Dapr installation instructions can be found [here](https://docs.dapr.io/getting-started/install-dapr-cli/). After installing the Dapr CLI, remember to run `dapr init` as described [here](https://docs.dapr.io/getting-started/install-dapr-selfhost/).

This sample is written in C# and targets .NET 8.0. It requires the [.NET 8.0 SDK](https://dotnet.microsoft.com/download/dotnet/8.0) or later.

## Building the sample
Expand Down

This file was deleted.

This file was deleted.

5 changes: 3 additions & 2 deletions samples/AspireWithNode/AspireWithNode.AppHost/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
var builder = DistributedApplication.CreateBuilder(args);

var cache = builder.AddRedisContainer("cache");
var cache = builder.AddRedis("cache");

var weatherapi = builder.AddProject<Projects.AspireWithNode_AspNetCoreApi>("weatherapi");

builder.AddNpmApp("frontend", "../NodeFrontend", "watch")
.WithReference(weatherapi)
.WithReference(cache)
.WithServiceBinding(scheme: "http");
.WithServiceBinding(containerPort: 3000, scheme: "http", env: "PORT")
.AsDockerfileInManifest();

builder.Build().Run();
47 changes: 47 additions & 0 deletions samples/AspireWithNode/AspireWithNode.AppHost/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"resources": {
"cache": {
"type": "redis.v0"
},
"weatherapi": {
"type": "project.v0",
"path": "../AspireWithNode.AspNetCoreApi/AspireWithNode.AspNetCoreApi.csproj",
"env": {
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true"
},
"bindings": {
"http": {
"scheme": "http",
"protocol": "tcp",
"transport": "http"
},
"https": {
"scheme": "https",
"protocol": "tcp",
"transport": "http"
}
}
},
"frontend": {
"type": "dockerfile.v0",
"path": "../NodeFrontend/Dockerfile",
"context": "../NodeFrontend",
"env": {
"NODE_ENV": "development",
"ConnectionStrings__cache": "{cache.connectionString}",
"services__weatherapi__0": "{weatherapi.bindings.http.url}",
"services__weatherapi__1": "{weatherapi.bindings.https.url}",
"PORT": "{frontend.bindings.http.port}"
},
"bindings": {
"http": {
"scheme": "http",
"protocol": "tcp",
"transport": "http",
"containerPort": 3000
}
}
}
}
}
2 changes: 2 additions & 0 deletions samples/AspireWithNode/NodeFrontend/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# .npmrc
engine-strict=true
12 changes: 12 additions & 0 deletions samples/AspireWithNode/NodeFrontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:20.10

WORKDIR /app

COPY package.json package.json
COPY package-lock.json package-lock.json

RUN npm install

COPY . .

CMD [ "node", "app.js" ]
20 changes: 17 additions & 3 deletions samples/AspireWithNode/NodeFrontend/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,25 @@ const port = env.PORT ?? 8080;

const cacheAddress = env['ConnectionStrings__cache'];
const apiServer = env['services__weatherapi__1'];
const passwordPrefix = ",password=";

var cacheConfig = {
url: `redis://${cacheAddress}`
};

let cachePasswordIndex = cacheAddress.indexOf(passwordPrefix);

if (cachePasswordIndex > 0) {
cacheConfig = {
url: `redis://${cacheAddress.substring(0, cachePasswordIndex)}`,
password: cacheAddress.substring(cachePasswordIndex + passwordPrefix.length)
}
}

console.log(`cacheAddress: ${cacheAddress}`);
console.log(`apiServer: ${apiServer}`);

const cache = createClient({ url: `redis://${cacheAddress}` });
const cache = createClient(cacheConfig);
cache.on('error', err => console.log('Redis Client Error', err));
await cache.connect();

Expand All @@ -36,7 +50,7 @@ app.set('view engine', 'pug');

const server = createServer(app)

async function healthCheck () {
async function healthCheck() {
const errors = [];
return Promise.all([
async () => {
Expand Down Expand Up @@ -72,6 +86,6 @@ createTerminus(server, {
onShutdown: () => console.log('cleanup finished, server is shutting down')
});

server.listen(port, () => {
server.listen(port, () => {
console.log(`Listening on port ${port}`);
});
3 changes: 3 additions & 0 deletions samples/AspireWithNode/NodeFrontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions samples/AspireWithNode/NodeFrontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"version": "1.0.0",
"type": "module",
"main": "app.js",
"engines": {
"node": ">=20.10"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node --watch --import ./instrumentation.js app.js",
Expand Down