Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stockbal/dotnet-cf-mvp
.NET Demo for SAP BTP Cloud Foundry
https://github.com/stockbal/dotnet-cf-mvp
cloudfoundry csharp mta xsuaa
Last synced: 14 days ago
JSON representation
.NET Demo for SAP BTP Cloud Foundry
- Host: GitHub
- URL: https://github.com/stockbal/dotnet-cf-mvp
- Owner: stockbal
- License: mit
- Created: 2024-05-14T14:56:10.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-05-16T10:18:32.000Z (8 months ago)
- Last Synced: 2024-11-02T08:42:27.997Z (2 months ago)
- Topics: cloudfoundry, csharp, mta, xsuaa
- Language: C#
- Homepage:
- Size: 27.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# .NET Core demo project for MTA deployment to Cloud Foundry
This demo project shows a very simple ASP.NET Web API service that returns hello world. It is secured with XSUAA from SAP BTP and can be deployed via `mta.yaml` to SAP BTP Cloud Foundry Environment.
It can be used as a template to build more complex multi-target that require a .NET module.## Securing your application with XSUAA
There is no standard NuGet package available (e.g. `@sap/xssec` for CAP NodeJS) to easily connect to the defined security configuration in `xs-security.json`, so this has to be done manually in the project.
Have a look in the [Authentication](./dotnet-module/src/DemoService/Authentication/ConfigureJwtBearerOptions.cs) folder to see how this can be done.
| :exclamation: The implementation is reverse engineered from [@sap/xssec](https://www.npmjs.com/package/@sap/xssec). Use at your own risk :smile: :exclamation: |
|-----------------------------------------|## Specifics for .NET Core MTA deployment
### MTA.yaml
A workaround for the builder is required, as `dotnet_core` is no longer a recognized and valid application type.
In this sample we use the `nodejs` module type and overwrite the builder with a dummy `echo` command. As we use a *source-based* deployment, no build for the .NET module is required.
The actual build will be done via the buildpack during the set-up of the container.```yaml
modules:
- name: my-dotnet-service-module
type: nodejs
path:
build-parameters:
builder: custom
commands:
- echo ">> Building .NET module"
...
```Additionally, the *online* build pack for .NET has been removed in Nov 16, 2023 (SAP note 3364781), so we need to specify a valid one in the `parameters` section of the module.
The repository [dotnet-core-buildpack](https://github.com/cloudfoundry/dotnet-core-buildpack) in the Cloud Foundry org holds different releases. If you require a certain stack (i.e. concrete .NET Core version) you can use a specific release by adding the release tag after the repository url.```yaml
...
parameters:
buildpack: https://github.com/cloudfoundry/dotnet-core-buildpack.git#v2.4.27
```### Setting buildpack options
To define certain options for the used buildpack we need to create an additional file called `buildpack.yml` in the root path of the .NET module.
Here we can set the .NET version to be used:
```yaml
---
dotnet-core:
sdk: 8.0
```### Defining your main .NET project
If you have several projects in your module you need to specify your main project in a file `.deployment` at root level of the .NET module:
```ini
[config]
project = src/DemoService/DemoService.csproj
```### Build/Deployment to SAP BTP Cloud foundry
```shell
mbt build --mtar archive
# login to cloud foundry and choose space for deployment
# cf l
cf deploy mta_archives/archive.mtar
```## Links
- [Cloud Foundry docs | .NET Buildpack](https://docs.cloudfoundry.org/buildpacks/dotnet-core/index.html)
- [.NET Core CF Buildpack](https://github.com/cloudfoundry/dotnet-core-buildpack)
- [.NET CLI installation | Linux](https://learn.microsoft.com/de-de/dotnet/core/install/linux-scripted-manual#scripted-install)