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

Update sample to dotnet 8, use simplified API, simplify authentication #62

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
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
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*.user
*.userosscache
*.sln.docstates

*/**/appsettings.local.json
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

Expand Down Expand Up @@ -221,7 +221,7 @@ ClientBin/
*.publishsettings
orleans.codegen.cs

# Including strong name files can present a security risk
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk

Expand Down Expand Up @@ -317,7 +317,7 @@ __pycache__/
# OpenCover UI analysis results
OpenCover/

# Azure Stream Analytics local run output
# Azure Stream Analytics local run output
ASALocalRun/

# MSBuild Binary and Structured Log
Expand All @@ -326,6 +326,6 @@ ASALocalRun/
# NVidia Nsight GPU debugger configuration file
*.nvuser

# MFractors (Xamarin productivity tool) working folder
# MFractors (Xamarin productivity tool) working folder
.mfractor/
/src/docker-compose.override.yml
/src/docker-compose.override.yml
8 changes: 4 additions & 4 deletions deploy/connection-string/deploy-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ spec:
- name: order-processor
image: ghcr.io/kedacore/sample-dotnet-worker-servicebus-queue:latest
env:
- name: KEDA_SERVICEBUS_AUTH_MODE
- name: OrderQueueOptions__AuthMode
value: ConnectionString
- name: KEDA_SERVICEBUS_QUEUE_CONNECTIONSTRING
- name: OrderQueueOptions__ConnectionString
valueFrom:
secretKeyRef:
name: secrets-order-consumer
key: servicebus-connectionstring
- name: KEDA_SERVICEBUS_QUEUE_NAME
- name: OrderQueueOptions__QueueName
value: orders
---
apiVersion: v1
Expand All @@ -34,4 +34,4 @@ metadata:
labels:
app: order-processor
data:
servicebus-connectionstring: <base64-encoded-connection-string>
servicebus-connectionstring: <base64-encoded-connection-string>
9 changes: 7 additions & 2 deletions deploy/deploy-web.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,23 @@ spec:
- name: order-web
image: ghcr.io/kedacore/sample-dotnet-worker-servicebus-portal
env:
- name: KEDA_SERVICEBUS_QUEUE_CONNECTIONSTRING
- name: OrderQueueOptions__AuthMode
value: ConnectionString
env:
- name: OrderQueueOptions__ConnectionString
valueFrom:
secretKeyRef:
name: secrets-order-portal
key: servicebus-connectionstring
- name: OrderQueueOptions__QueueName
value: orders
---
apiVersion: v1
kind: Service
metadata:
name: kedasampleweb
labels:
app: order-web
app: order-web
annotations:
# Expose service on <label-name>.<location>.cloudapp.azure.com
service.beta.kubernetes.io/azure-dns-label-name: keda-orders-portal
Expand Down
10 changes: 5 additions & 5 deletions deploy/pod-identity/deploy-app-with-pod-identity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ spec:
- name: order-processor
image: ghcr.io/kedacore/sample-dotnet-worker-servicebus-queue:latest
env:
- name: KEDA_SERVICEBUS_AUTH_MODE
- name: OrderQueueOptions__AuthMode
Copy link
Member

Choose a reason for hiding this comment

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

Let's revert all of these renames and stick with current names

Copy link
Author

Choose a reason for hiding this comment

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

I would prefer to, but I don't know how when using DotNets option pattern., do you have any advice?

I could revert the configuration integration and just parse it myself in the options class, if that is preferable?

Copy link
Member

Choose a reason for hiding this comment

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

Let's revert it for now and keep it simple

Copy link
Author

Choose a reason for hiding this comment

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

Can I suggest an upgrade?

In the fork we have removed all auth options, and only retained AzureDefaultCredentials... What do you think about the same here, but also only checking if KEDA_SERVICEBUS_CONNECTION_STRING is used, and if so, only using that?

Copy link
Author

Choose a reason for hiding this comment

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

btw, that was my last question, if you still want to retain the original features, I'll get right on it :)

value: PodIdentity
- name: KEDA_SERVICEBUS_HOST_NAME
- name: OrderQueueOptions__FullyQualifiedNamespace
value: <namespace-name>.servicebus.windows.net
- name: KEDA_SERVICEBUS_QUEUE_NAME
- name: OrderQueueOptions__QueueName
value: orders
- name: KEDA_SERVICEBUS_IDENTITY_USERASSIGNEDID
value: <app-identity-id>
- name: OrderQueueOptions__ClientId
value: <app-identity-id>
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ spec:
- name: order-processor
image: ghcr.io/kedacore/sample-dotnet-worker-servicebus-queue:latest
env:
- name: KEDA_SERVICEBUS_AUTH_MODE
- name: OrderQueueOptions__AuthMode
value: WorkloadIdentity
- name: KEDA_SERVICEBUS_HOST_NAME
- name: OrderQueueOptions__FullyQualifiedNamespace
value: <namespace-name>.servicebus.windows.net
- name: KEDA_SERVICEBUS_QUEUE_NAME
- name: OrderQueueOptions__QueueName
value: orders
2 changes: 1 addition & 1 deletion pod-identity.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ To build and run the web app locally, add the service bus connection string to a
There is also a docker image available, so you can also run it locally with the following command:

```cli
docker run -p 8080:80 -d -e OrderQueue__ConnectionString="KEDA_SERVICEBUS_QUEUE_CONNECTIONSTRING" kedasamples/sample-dotnet-web
docker run -p 8080:80 -d -e OrderQueue__ConnectionString="<connection-string>" kedasamples/sample-dotnet-web
```

To deploy the web application to your Kubernetes cluster:
Expand Down
47 changes: 0 additions & 47 deletions src/Keda.Samples.DotNet.Web/Controllers/OrdersController.cs

This file was deleted.

37 changes: 0 additions & 37 deletions src/Keda.Samples.DotNet.Web/Controllers/QueueController.cs

This file was deleted.

4 changes: 2 additions & 2 deletions src/Keda.Samples.DotNet.Web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1.1-alpine AS base
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/core/sdk:3.1.101-alpine AS build
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["Keda.Samples.DotNet.Web/Keda.Samples.DotNet.Web.csproj", "Keda.Samples.DotNet.Web/"]
COPY ["Keda.Samples.Dotnet.Contracts/Keda.Samples.Dotnet.Contracts.csproj", "Keda.Samples.Dotnet.Contracts/"]
Expand Down

This file was deleted.

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

24 changes: 9 additions & 15 deletions src/Keda.Samples.DotNet.Web/Keda.Samples.DotNet.Web.csproj
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>12</LangVersion>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
<UserSecretsId>858adc6c-c378-4698-a3c4-1112a29d6561</UserSecretsId>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DocumentationFile>Keda.Samples.DotNet.Web.Open-Api.xml</DocumentationFile>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Guard.Net" Version="1.2.0" />
<PackageReference Include="Microsoft.Azure.Management.ServiceBus" Version="2.1.0" />
<PackageReference Include="Microsoft.Azure.ServiceBus" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.1" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.9.10" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="5.0.0" />
<PackageReference Include="Guard.Net" Version="3.0.0" />
<PackageReference Include="Azure.Messaging.ServiceBus" Version="7.17.5" />
<PackageReference Include="Microsoft.Azure.Management.ServiceBus" Version="5.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.6.2" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.6.2" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
7 changes: 0 additions & 7 deletions src/Keda.Samples.DotNet.Web/OrderQueueSettings.cs

This file was deleted.

8 changes: 0 additions & 8 deletions src/Keda.Samples.DotNet.Web/Pages/Error.cshtml
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
@page
@model ErrorModel
@{
ViewData["Title"] = "Error";
}

<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>

@if (Model.ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}

<h3>Development Mode</h3>
<p>
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
Expand Down
31 changes: 0 additions & 31 deletions src/Keda.Samples.DotNet.Web/Pages/Error.cshtml.cs

This file was deleted.

19 changes: 0 additions & 19 deletions src/Keda.Samples.DotNet.Web/Pages/Index.cshtml.cs

This file was deleted.

1 change: 0 additions & 1 deletion src/Keda.Samples.DotNet.Web/Pages/Privacy.cshtml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@page
@model PrivacyModel
@{
ViewData["Title"] = "Privacy Policy";
}
Expand Down
Loading