> For the complete documentation index, see [llms.txt](https://docs.solutioo.de/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.solutioo.de/dpd-connector-premium/azure-integrationen/uberblick-and-anbindung-s2s-oauth.md).

# Überblick & Anbindung (S2S/OAuth)

## Überblick & Anbindung (S2S/OAuth)

Die Azure Function **`DpdTrackingPush`** verarbeitet DPD-Statusdaten und schreibt sie über die Business-Central-**OData-v4-API** zurück. Dazu ist eine einmalige **Service-to-Service-Anbindung (OAuth)** nötig.

### Architektur

```mermaid
flowchart LR
    DPD["DPD"] -->|HTTP GET Push| AF["Azure Function"]
    DPD -->|SFTP Pull| AF
    AF -->|OAuth2 S2S| API["BC API\nsolutioo/dpd/v1.0"]
    API --> BC["Paketstatus / POD in BC"]
```

### BC-API-Endpunkte

Diese Endpunkte hinterlegen Sie in der Azure Function (Platzhalter ersetzen):

```
https://<env>.api.businesscentral.dynamics.com/v2.0/<company>/api/solutioo/dpd/v1.0/companies(<companyId>)/trackingEvents
https://<env>.api.businesscentral.dynamics.com/v2.0/<company>/api/solutioo/dpd/v1.0/companies(<companyId>)/proofOfDeliveries
```

### Einmalige Anbindung

{% stepper %}
{% step %}

#### Entra App-Registrierung

Eine App-Registrierung anlegen (z. B. „DPD Tracking Push (BC S2S)") und ein **Client-Secret** erzeugen. Client-ID und Secret in die App-Settings der Function eintragen.
{% endstep %}

{% step %}

#### S2S in Business Central freischalten

In BC **Microsoft Entra-Anwendungen** öffnen, die **Client-ID** eintragen, Status = **Aktiviert** und den Berechtigungssatz **`SOUDPDConnector`** (oder `D365 AUTOMATION` + DPD) zuweisen.
{% endstep %}

{% step %}

#### Company-GUID ermitteln

`GET .../v2.0/<env>/api/v2.0/companies` → die `id` als `BC_COMPANY_ID` in der Function hinterlegen.
{% endstep %}

{% step %}

#### Push bei DPD registrieren

Beim DPD-Kundencenter die Push-URL hinterlegen (siehe Tracking-Push-Service).
{% endstep %}
{% endstepper %}

### App-Settings (Kern)

| Setting            | Beschreibung                                                      |
| ------------------ | ----------------------------------------------------------------- |
| `BC_TENANT_ID`     | Entra-Tenant-GUID                                                 |
| `BC_CLIENT_ID`     | Client-ID der App-Registrierung                                   |
| `BC_CLIENT_SECRET` | Client-Secret                                                     |
| `BC_ENVIRONMENT`   | z. B. `Production` oder `Sandbox`                                 |
| `BC_COMPANY_ID`    | GUID des BC-Mandanten                                             |
| `BC_API_BASE`      | optional, Default `https://api.businesscentral.dynamics.com/v2.0` |

{% hint style="info" %}
Deployment erfolgt über das mitgelieferte Skript `deploy.sh` (Resource Group, Storage Account und Function App werden idempotent angelegt). Runtime: Node auf Azure Functions v4, Windows Consumption Plan.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.solutioo.de/dpd-connector-premium/azure-integrationen/uberblick-and-anbindung-s2s-oauth.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
