Konfigurieren von Microsoft Entra Private Access mithilfe von Microsoft Graph-APIs

Microsoft Entra Private Access ermöglicht den sicheren Remotezugriff auf lokale Apps, ohne dass ein VPN erforderlich ist.

In diesem Tutorial wird erläutert, wie Sie Microsoft Entra Private Access mithilfe von Microsoft Graph-Netzwerkzugriffs-APIs konfigurieren. Sie gehen dann so vor:

  • Erstellen Sie eine benutzerdefinierte App, um Back-End-App-Einstellungen zu konfigurieren.
  • Richten Sie Microsoft Entra Anwendungsproxy für den privaten Zugriff ein.

Wichtig

Einige API-Vorgänge in diesem Tutorial verwenden den beta Endpunkt.

Voraussetzungen

Gehen Sie wie folgt vor, um dieses Tutorial zu befolgen:

  • Sie verfügen über einen Microsoft Entra Mandanten mit der Microsoft Entra Suite-Lizenz.
  • Installieren und einrichten Sie den Connector für den Privaten Netzwerkzugriff. Weitere Informationen finden Sie unter Hinzufügen einer lokalen Anwendung für den Remotezugriff über den Anwendungsproxy in Microsoft Entra ID.
  • Melden Sie sich bei einem API-Client wie Graph Explorer mit einem Konto an, das über die erforderlichen Administratorrollen verfügt. Die folgenden Microsoft Entra Rollen sind für dieses Tutorial mindestens erforderlich:
    • Anwendungsadministrator zum Erstellen der App.
    • Globaler Administrator für sicheren Zugriff zum Konfigurieren der Einstellungen für den globalen sicheren Zugriff in der App.
  • Erteilen Sie der App die delegierten Berechtigungen Directory.ReadWrite.All und NetworkAccess.ReadWrite.All .
  • Bitten Sie einen Testbenutzer, der der App zugewiesen werden soll.

Schritt 1: Erstellen einer benutzerdefinierten Anwendung

Um den Anwendungsproxy einzurichten, erstellen Sie zunächst eine benutzerdefinierte Anwendung, und aktualisieren Sie dann die App-Proxyeinstellungen in der onPremisesPublishing-Eigenschaft .

Verwenden Sie eine Anwendungsvorlage, um eine benutzerdefinierte Anwendung und einen Dienstprinzipal in Ihrem Mandanten zu erstellen. Die Vorlagen-ID für eine benutzerdefinierte Anwendung lautet 8adf8e6e-67b2-4cf2-a259-e3dc5476c621. Sie finden sie, indem Sie diese Abfrage ausführen: GET https://graph.microsoft.com/v1.0/applicationTemplates?$filter=displayName eq 'Custom'.

Notieren Sie sich in der Antwort die ID des Dienstprinzipals und der Anwendungsobjekte sowie die appId zur späteren Verwendung.

Die folgende Anforderung erstellt eine benutzerdefinierte Anwendung namens newPrivateApp.

Anforderung

POST https://graph.microsoft.com/v1.0/applicationTemplates/8adf8e6e-67b2-4cf2-a259-e3dc5476c621/instantiate
Content-type: application/json

{ 
   "displayName": "newPrivateApp" 
} 

Antwort

HTTP/1.1 201 Created
Content-type: application/json

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#microsoft.graph.applicationServicePrincipal",
    "application": {
        "id": "bf21f7e9-9d25-4da2-82ab-7fdd85049f83",
        "appId": "32977d3b-ee0e-4614-9f50-f583a07842d2",
        "applicationTemplateId": "8adf8e6e-67b2-4cf2-a259-e3dc5476c621",
        "createdDateTime": "2024-02-22T16:48:09Z",
        "deletedDateTime": null,
        "displayName": "newPrivateApp",
        "description": null,
        "groupMembershipClaims": null,
        "identifierUris": [],
        "isFallbackPublicClient": false,
        "signInAudience": "AzureADMyOrg",
        "tags": [],
        "tokenEncryptionKeyId": null,
        "defaultRedirectUri": null,
        "samlMetadataUrl": null,
        "optionalClaims": null,
        "addIns": [],
        "api": {
            "acceptMappedClaims": null,
            "knownClientApplications": [],
            "requestedAccessTokenVersion": null,
            "oauth2PermissionScopes": [
                {
                    "adminConsentDescription": "Allow the application to access newPrivateApp on behalf of the signed-in user.",
                    "adminConsentDisplayName": "Access newPrivateApp",
                    "id": "5cda2e1e-d9fd-4f69-b981-48fbc8a16be1",
                    "isEnabled": true,
                    "type": "User",
                    "userConsentDescription": "Allow the application to access newPrivateApp on your behalf.",
                    "userConsentDisplayName": "Access newPrivateApp",
                    "value": "user_impersonation"
                }
            ],
            "preAuthorizedApplications": []
        },
        "appRoles": [
            {
                "allowedMemberTypes": [
                    "User"
                ],
                "displayName": "User",
                "id": "18d14569-c3bd-439b-9a66-3a2aee01d14f",
                "isEnabled": true,
                "description": "User",
                "value": null,
                "origin": "Application"
            },
            {
                "allowedMemberTypes": [
                    "User"
                ],
                "displayName": "msiam_access",
                "id": "b9632174-c057-4f7e-951b-be3adc52bfe6",
                "isEnabled": true,
                "description": "msiam_access",
                "value": null,
                "origin": "Application"
            }
        ],
        "info": {
            "logoUrl": null,
            "marketingUrl": null,
            "privacyStatementUrl": null,
            "supportUrl": null,
            "termsOfServiceUrl": null
        },
        "keyCredentials": [],
        "parentalControlSettings": {
            "countriesBlockedForMinors": [],
            "legalAgeGroupRule": "Allow"
        },
        "passwordCredentials": [],
        "publicClient": {
            "redirectUris": []
        },
        "requiredResourceAccess": [],
        "verifiedPublisher": {
            "displayName": null,
            "verifiedPublisherId": null,
            "addedDateTime": null
        },
        "web": {
            "homePageUrl": "https://account.activedirectory.windowsazure.com:444/applications/default.aspx?metadata=customappsso|ISV9.1|primary|z",
            "redirectUris": [],
            "logoutUrl": null
        }
    },
    "servicePrincipal": {
        "id": "a8cac399-cde5-4516-a674-819503c61313",
        "deletedDateTime": null,
        "accountEnabled": true,
        "appId": "32977d3b-ee0e-4614-9f50-f583a07842d2",
        "applicationTemplateId": "8adf8e6e-67b2-4cf2-a259-e3dc5476c621",
        "appDisplayName": "newPrivateApp",
        "alternativeNames": [],
        "appOwnerOrganizationId": "38d49456-54d4-455d-a8d6-c383c71e0a6d",
        "displayName": "newPrivateApp",
        "appRoleAssignmentRequired": true,
        "loginUrl": null,
        "logoutUrl": null,
        "homepage": "https://account.activedirectory.windowsazure.com:444/applications/default.aspx?metadata=customappsso|ISV9.1|primary|z",
        "notificationEmailAddresses": [],
        "preferredSingleSignOnMode": null,
        "preferredTokenSigningKeyThumbprint": null,
        "replyUrls": [],
        "servicePrincipalNames": [
            "32977d3b-ee0e-4614-9f50-f583a07842d2"
        ],
        "servicePrincipalType": "Application",
        "tags": [
            "WindowsAzureActiveDirectoryCustomSingleSignOnApplication",
            "WindowsAzureActiveDirectoryIntegratedApp"
        ],
        "tokenEncryptionKeyId": null,
        "samlSingleSignOnSettings": null,
        "addIns": [],
        "appRoles": [
            {
                "allowedMemberTypes": [
                    "User"
                ],
                "displayName": "User",
                "id": "18d14569-c3bd-439b-9a66-3a2aee01d14f",
                "isEnabled": true,
                "description": "User",
                "value": null,
                "origin": "Application"
            },
            {
                "allowedMemberTypes": [
                    "User"
                ],
                "displayName": "msiam_access",
                "id": "b9632174-c057-4f7e-951b-be3adc52bfe6",
                "isEnabled": true,
                "description": "msiam_access",
                "value": null,
                "origin": "Application"
            }
        ],
        "info": {
            "logoUrl": null,
            "marketingUrl": null,
            "privacyStatementUrl": null,
            "supportUrl": null,
            "termsOfServiceUrl": null
        },
        "keyCredentials": [],
        "oauth2PermissionScopes": [
            {
                "adminConsentDescription": "Allow the application to access newPrivateApp on behalf of the signed-in user.",
                "adminConsentDisplayName": "Access newPrivateApp",
                "id": "5cda2e1e-d9fd-4f69-b981-48fbc8a16be1",
                "isEnabled": true,
                "type": "User",
                "userConsentDescription": "Allow the application to access newPrivateApp on your behalf.",
                "userConsentDisplayName": "Access newPrivateApp",
                "value": "user_impersonation"
            }
        ],
        "passwordCredentials": [],
        "verifiedPublisher": {
            "displayName": null,
            "verifiedPublisherId": null,
            "addedDateTime": null
        }
    }
}

Schritt 2: Angeben des Typs der privaten Anwendung

Sie können eine private App für globalen sicheren Zugriff entweder als Schnellzugriffs- oder Unternehmens-App erstellen. Legen Sie die Eigenschaft application>onPremisesPublishing>applicationType für Schnellzugriffs-Apps oder nonwebapp Unternehmens-Apps auf quickaccessapp fest.

In diesem Schritt richten Sie eine private App für globalen sicheren Zugriff als Unternehmens-App ein.

Die Anforderung gibt eine 204 No Content Antwort zurück.

PATCH https://graph.microsoft.com/beta/applications/bf21f7e9-9d25-4da2-82ab-7fdd85049f83

{
   "onPremisesPublishing":{
      "applicationType":"nonwebapp",
      "isAccessibleViaZTNAClient": true
   }
}

Schritt 3: Zuweisen einer Connectorgruppe zur Anwendung

Schritt 3.1: Abrufen von Connectors

Identifizieren Sie den Connector, den Sie der Connectorgruppe zuweisen möchten. Notieren Sie sich die ID.

Anforderung

GET https://graph.microsoft.com/beta/onPremisesPublishingProfiles/applicationProxy/connectors

Antwort

HTTP/1.1 200 OK
Content-type: application/json

{
  "@odata.context": "https://graph.microsoft.com/beta/$metadata#onPremisesPublishingProfiles('applicationProxy')/connectors",
  "@microsoft.graph.tips": "Use $select to choose only the properties your app needs, as this can lead to performance improvements. For example: GET onPremisesPublishingProfiles('<key>')/connectors?$select=externalIp,machineName",
  "value": [
    {
      "id": "d2b1e8e8-8511-49d6-a4ba-323cb083fbb0",
      "machineName": "connectorA.redmond.contoso.com",
      "externalIp": "131.137.147.164",
      "status": "active"
    },
    {
      "id": "f2cab422-a1c8-4d70-a47e-2cb297a2e051",
      "machineName": "connectorB.contoso.com",
      "externalIp": "68.0.191.210",
      "status": "active"
    }
  ]
}

Schritt 3.2: Erstellen einer connectorGroup

Erstellen Sie eine connectorGroup mit dem Namen Private Access ConnectorGroup für die Anwendung. Notieren Sie sich die ID.

Anforderung

POST https://graph.microsoft.com/beta/onPremisesPublishingProfiles/applicationProxy/connectorGroups
Content-type: application/json

{
  "name": "Private Access ConnectorGroup"
}

Antwort

HTTP/1.1 201 Created
Content-type: application/json

{
  "@odata.context": "https://graph.microsoft.com/beta/$metadata#connectorGroups/$entity",
  "id": "daf709c2-6072-414f-b08c-bb2a80c631c",
  "name": "Private Access ConnectorGroup",
  "connectorGroupType": "applicationProxy",
  "region": "eur",
  "isDefault": false
}

Schritt 3.3: Zuweisen eines Connectors zur connectorGroup

Die folgende Anforderung gibt eine 204 No content Antwort zurück.

POST https://graph.microsoft.com/beta/onPremisesPublishingProfiles/applicationProxy/connectors/27049d40-6e0a-4c53-a171-daada6e9c8a0/memberOf/$ref
Content-type: application/json

{
  "@odata.id":"https://graph.microsoft.com/beta/onPremisesPublishingProfiles/applicationProxy/connectorGroups/daf709c2-6072-414f-b08c-bb2a80c631c"
}

Schritt 3.4: Zuweisen der privaten App zur Connectorgruppe

Die folgende Anforderung gibt eine 204 No content Antwort zurück.

PUT https://graph.microsoft.com/beta/applications/bf21f7e9-9d25-4da2-82ab-7fdd85049f83/connectorGroup/$ref
Content-type: application/json

{
  "@odata.id":"https://graph.microsoft.com/beta/onPremisesPublishingProfiles/applicationproxy/connectorGroups/daf709c2-6072-414f-b08c-bb2a80c631c"
}

Schritt 4: Hinzufügen von Anwendungssegmenten zur privaten Anwendung

Erstellen Sie im Beispiel ein neues App-Segment mit den folgenden Einstellungen:

  • Ersetzen Sie den Wert von destinationHost durch das private App-Ziel.
  • Ersetzen Sie den Wert von destinationType durch ipAddress, ipRange, ipRangeCidr, fqdnoder dnsSuffix.
  • Ersetzen Sie den Wert des Protokolls entweder durch tcp, udpoder tcp,udp , je nachdem, welche Protokolle Ihre App verwendet.

Anforderung

POST https://graph.microsoft.com/beta/applications/bf21f7e9-9d25-4da2-82ab-7fdd85049f83/onPremisesPublishing/segmentsConfiguration/microsoft.graph.ipSegmentConfiguration/applicationSegments

{
   "destinationHost": "test2.com",
   "destinationType": "fqdn",
   "port": 0,
   "ports": [
      "445-445",
      "3389-3389"
   ],
   "protocol": "tcp"
}

Antwort

HTTP/1.1 200 OK
Content-type: application/json

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#applications('8706aca4-94e9-4783-a23d-7dae1599a6e0')/onPremisesPublishing/segmentsConfiguration/microsoft.graph.ipSegmentConfiguration/applicationSegments/$entity",
    "destinationHost": "test2.com",
    "destinationType": "fqdn",
    "port": 0,
    "ports": [
        "445-445",
        "3389-3389"
    ],
    "protocol": "tcp",
    "id": "2b52958c-9d0c-449d-a985-c29d488a6335"
}

[Optional] Aktualisieren oder Löschen eines vorhandenen App-Segments

Die folgende Anforderung aktualisiert ein vorhandenes Segment, indem das Protokoll in tcp und udpgeändert wird. Die Anforderung gibt einen 204 No Content Antwortcode zurück.

PATCH https://graph.microsoft.com/beta/applications/bf21f7e9-9d25-4da2-82ab-7fdd85049f83/onPremisesPublishing/segmentsConfiguration/microsoft.graph.ipSegmentConfiguration/applicationSegments/{segmentID}

{ 
   "protocol":"tcp,udp" 
} 

Schritt 5: Zuweisen eines Benutzers zur privaten Anwendung

Weisen Sie den Benutzer dem Dienstprinzipal zu, und gewähren Sie ihm die User App-Rolle. Geben Sie im Anforderungstext die folgenden Werte an:

  • principalId : Die ID des Benutzerkontos, das Sie erstellt haben.
  • appRoleId : Die ID der Standard-App-Rolle User , die Sie aus dem Dienstprinzipal abgerufen haben.
  • resourceId : Die ID des Dienstprinzipals.

Anforderung

POST https://graph.microsoft.com/beta/servicePrincipals/a8cac399-cde5-4516-a674-819503c61313/appRoleAssignments
Content-type: application/json

{
  "principalId": "4628e7df-dff3-407c-a08f-75f08c0806dc",
  "principalType": "User",
  "appRoleId":"18d14569-c3bd-439b-9a66-3a2aee01d14f",
  "resourceId":"a8cac399-cde5-4516-a674-819503c61313"
}

Antwort

HTTP/1.1 200 OK
Content-type: application/json

{
  "@odata.context": "https://graph.microsoft.com/beta/$metadata#appRoleAssignments/$entity",
  "id": "I23pL8ZdNU-CIgQmqMEVyLJ0E6fx0ixEo92az8MnhtU",
  "creationTimestamp": "2020-06-09T00:06:07.5129268Z",
  "appRoleId": "18d14569-c3bd-439b-9a66-3a2aee01d14f",
  "principalDisplayName": "MyTestUser1",
  "principalId": "4628e7df-dff3-407c-a08f-75f08c0806dc",
  "principalType": "User",
  "resourceDisplayName": "newPrivateApp",
  "resourceId": "a8cac399-cde5-4516-a674-819503c61313"
}

Schritt 6: Aktivieren des Private Access-Datenverkehrsweiterleitungsprofils für Ihren Mandanten

Schritt 6.1: Abrufen der Profile für die Weiterleitung von Datenverkehr für privaten Zugriff in Ihrem Mandanten

Notieren Sie sich die ID des zu verwendenden Profils.

Anforderung

GET https://graph.microsoft.com/beta/networkAccess/forwardingProfiles?$filter=trafficForwardingType eq 'private'

Antwort

HTTP/1.1 200 OK
Content-type: application/json

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#networkAccess/forwardingProfiles",
    "@microsoft.graph.tips": "Use $select to choose only the properties your app needs, as this can lead to performance improvements. For example: GET networkAccess/forwardingProfiles?$select=associations,priority",
    "value": [
        {
            "trafficForwardingType": "private",
            "priority": 1,
            "id": "983891f5-e561-40ca-a4d1-cf4540d9a000",
            "name": "Private access traffic forwarding profile",
            "description": "Default traffic forwarding profile for Private access traffic acquisition. Assign the profile to client or branch offices to acquire Private access traffic for Zero Trust Network Access.",
            "state": "enabled",
            "version": "1.0.0",
            "lastModifiedDateTime": "2024-03-12T17:35:36Z",
            "associations": [],
            "servicePrincipal": null
        }
    ]
}

Schritt 6.2: Aktivieren des Status des Weiterleitungsprofils für privaten Zugriff

Die Anforderung gibt eine 204 No content Antwort zurück.

PATCH https://graph.microsoft.com/beta/networkAccess/forwardingProfiles/983891f5-e561-40ca-a4d1-cf4540d9a000

{
   "state": "enabled"
}

Schritt 7: Aktivieren der dns-Auflösung (Private Domain Name System)

Diese Funktion ist nur für private Global Secure Access-Anwendungen vom Typ Schnellzugriff verfügbar. Die Anforderung gibt einen 204 No Content Antwortcode zurück.

PATCH https://graph.microsoft.com/beta/applications/bf21f7e9-9d25-4da2-82ab-7fdd85049f83/onPremisesPublishing

{ 
   "isDnsResolutionEnabled": true 
} 

Schritt 8: Erstellen eines neuen DNS-Suffixes

Anforderung

POST https://graph.microsoft.com/beta/applications/bf21f7e9-9d25-4da2-82ab-7fdd85049f83/onPremisesPublishing/segmentsConfiguration/microsoft.graph.ipSegmentConfiguration/applicationSegments

{ 
   "destinationHost": "app1.dns.com", 
   "destinationType": "dnsSuffix" 
} 

Antwort

HTTP/1.1 200 OK
Content-type: application/json

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#applications('71fe4b11-db80-4525-b7e9-f503fb748180')/onPremisesPublishing/segmentsConfiguration/microsoft.graph.ipSegmentConfiguration/applicationSegments/$entity",
    "destinationHost": "app3.dns.com",
    "destinationType": "dnsSuffix",
    "port": 0,
    "ports": [],
    "protocol": "0",
    "id": "6ce9df44-734d-4240-aa3b-789ecaf7b7ce"
}