{"id":16163549,"url":"https://github.com/stockbal/dotnet-cf-mvp","last_synced_at":"2025-10-18T23:43:46.010Z","repository":{"id":239781688,"uuid":"800554013","full_name":"stockbal/dotnet-cf-mvp","owner":"stockbal","description":".NET Demo for SAP BTP Cloud Foundry","archived":false,"fork":false,"pushed_at":"2025-01-07T08:54:05.000Z","size":74,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-13T08:53:48.017Z","etag":null,"topics":["cloudfoundry","csharp","mta","xsuaa"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stockbal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-14T14:56:10.000Z","updated_at":"2025-01-07T08:54:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"8f3a248e-e5d1-4f76-be5a-1ca1b3ebe9d8","html_url":"https://github.com/stockbal/dotnet-cf-mvp","commit_stats":null,"previous_names":["stockbal/dotnet-cf-mvp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stockbal%2Fdotnet-cf-mvp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stockbal%2Fdotnet-cf-mvp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stockbal%2Fdotnet-cf-mvp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stockbal%2Fdotnet-cf-mvp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stockbal","download_url":"https://codeload.github.com/stockbal/dotnet-cf-mvp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247595375,"owners_count":20963940,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudfoundry","csharp","mta","xsuaa"],"created_at":"2024-10-10T02:43:56.208Z","updated_at":"2025-10-18T23:43:40.952Z","avatar_url":"https://github.com/stockbal.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# .NET Core demo project for MTA deployment to Cloud Foundry\n\nThis 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.  \nIt can be used as a template to build more complex multi-target that require a .NET module.\n\n## Securing your application with XSUAA\n\nThere 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.\n\nHave a look in the [Authentication](./dotnet-module/src/DemoService/Authentication/ConfigureJwtBearerOptions.cs) folder to see how this can be done.\n\n| :exclamation:  The implementation is reverse engineered from [@sap/xssec](https://www.npmjs.com/package/@sap/xssec). Use at your own risk :smile:   :exclamation: |\n|-----------------------------------------|\n\n## JSON logging to support Application Logging or Cloud Logging Service\n\nLogging in JSON format is enabled via the  [Serilog](https://github.com/serilog/serilog) library and active in productive environment.  \nFor the logger property `logger` the triggering class name of the log event is used. The `correlation_id` is either taken from the request header `x-correlation-id` (e.g. if passed from another cf application) or a new UUID is created which will be added to each log message, that is created during a single request.\n\nThe project also contains a small [CAP](https://cap.cloud.sap) project to demonstrate the proper forwarding of the `correlation_id` when the .NET endpoint is called from CAP (see [proxy-service.js](./cap-module/srv/proxy-service.js)).\n\n## Specifics for .NET Core MTA deployment\n\n### MTA.yaml\n\nA workaround for the builder is required, as `dotnet_core` is no longer a recognized and valid application type.\n\nIn 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.  \nThe actual build will be done via the buildpack during the set-up of the container.\n\n```yaml\nmodules:\n  - name: my-dotnet-service-module\n    type: nodejs\n    path: \u003cpath-to-folder-with-.net-solution\u003e\n    build-parameters:\n      builder: custom\n      commands:\n        - echo \"\u003e\u003e Building .NET module\"\n    ...\n```\n\nAdditionally, 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.  \nThe 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.\n\n```yaml\n    ...\n    parameters:\n      buildpack: https://github.com/cloudfoundry/dotnet-core-buildpack.git#v2.4.27\n```\n\n### Setting buildpack options\n\nTo 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.\n\nHere we can set the .NET version to be used:\n\n```yaml\n---\ndotnet-core:\n  sdk: 8.0\n```\n\n### Defining your main .NET project\n\nIf 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:\n\n```ini\n[config]\nproject = src/DemoService/DemoService.csproj\n```\n\n### Build/Deployment to SAP BTP Cloud foundry\n\n```shell\nmbt build --mtar archive\n# login to cloud foundry and choose space for deployment\n# cf l\ncf deploy mta_archives/archive.mtar\n```\n\n### Testing the deployed service\n\nCreate `.env` file in folder `/test`, to execute the requests in [api-test.http](./test/api-test.http).\n\n```properties\n# Credentials of XSUAA instance\nuaaUrl=https://...\nclientId=\nclientSecret=\"\"\n\n# URLS of deployed CAP and .NET modules\nappUrl=https://...\ncapAppUrl=https://..\n\nuser_default_idp=\npw_default_idp=\"\"\n\n# If you have a custom IdP configured\nuser_custom_idp=\npw_custom_idp=\"\"\n```\n\n## Links\n\n- [Cloud Foundry docs | .NET Buildpack](https://docs.cloudfoundry.org/buildpacks/dotnet-core/index.html)\n- [.NET Core CF Buildpack](https://github.com/cloudfoundry/dotnet-core-buildpack)\n- [.NET CLI installation | Linux](https://learn.microsoft.com/de-de/dotnet/core/install/linux-scripted-manual#scripted-install)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstockbal%2Fdotnet-cf-mvp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstockbal%2Fdotnet-cf-mvp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstockbal%2Fdotnet-cf-mvp/lists"}