Megosztás a következőn keresztül:


Hitelesítési módok az események célhelyekre való rögzítéséhez az Azure Event Hubsban

Az Azure Event Hubs lehetővé teszi különböző hitelesítési módok kiválasztását, amikor eseményeket rögzít egy célhelyre, például az Azure Blob Storage-ba vagy az 1. generációs Azure Data Lake Storage-fiókba vagy a 2 . generációs Azure Data Lake Storage-fiókba. A hitelesítési mód határozza meg, hogy az Event Hubsban futó rögzítési ügynök hogyan hitelesít a rögzítési célhelyen.

SAS-alapú hitelesítés

Az alapértelmezett hitelesítési módszer a közös hozzáférésű jogosultságkód (SAS) használata a rögzítési cél eléréséhez az Event Hubs szolgáltatásból.

Az Event Hubs-adatok Azure Storage-ba vagy Azure Data Lake Storage-ba való rögzítését ábrázoló kép alapértelmezett SAS-hitelesítési móddal

Ezzel a módszerrel adatokat rögzíthet olyan célerőforrásokra, amelyek csak ugyanabban az előfizetésben találhatók.

Felügyelt identitás használata

A felügyelt identitással a felhasználók zökkenőmentesen rögzíthetik az adatokat egy előnyben részesített célhelyre a Microsoft Entra ID-alapú hitelesítéssel és engedélyezéssel.

Az Event Hubs-adatok Az Azure Storage-ba vagy az Azure Data Lake Storage-ba történő rögzítését ábrázoló kép felügyelt identitás használatával

A rendszer által hozzárendelt vagy felhasználó által hozzárendelt felügyelt identitásokat az Event Hubs Capture célhelyeivel használhatja.

Események rögzítése rendszer által hozzárendelt felügyelt identitással

A rendszer automatikusan létrehozza és hozzárendeli a rendszer által hozzárendelt felügyelt identitást egy Azure-erőforráshoz, amely ebben az esetben egy Event Hubs-névtér.

A rendszer által hozzárendelt identitás használatához a rögzítési célhelynek engedélyeznie kell a megfelelő rendszer által hozzárendelt identitáshoz szükséges szerepkör-hozzárendelést. Ezután kiválaszthatja System Assigned a felügyelt identitás lehetőséget, amikor engedélyezi a rögzítési funkciót egy eseményközpontban.

Az Event Hubs-adatok Azure Storage-ba vagy Azure Data Lake Storage-ba való rögzítését ábrázoló kép a rendszer által hozzárendelt felügyelt identitás használatával.

Ezután a rögzítési ügynök a névtér identitását használja a hitelesítéshez és az engedélyezéshez a rögzítési célhelyen.

Azure Resource Manager-sablon

Az alábbi példa Azure Resource Manager-sablonnal konfigurálhatja az adatok rögzítését egy rendszer által hozzárendelt felügyelt identitás használatával.

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "namespaces_eventhubcapture_name": {
            "defaultValue": "eventhubcapturens",
            "type": "String"
        },
        "captureEnabled": {
            "defaultValue": true,
            "type": "Bool",
            "metadata": {
                "description": "Enable or disable the Capture feature for your event hub."
            }
        },
        "captureEncodingFormat": {
            "defaultValue": "Avro",
            "allowedValues": [
                "Avro"
            ],
            "type": "String",
            "metadata": {
                "description": "The encoding format that Event Hubs Capture uses to serialize the event data when archiving to your storage."
            }
        },
        "captureTime": {
            "defaultValue": 300,
            "minValue": 60,
            "maxValue": 900,
            "type": "Int",
            "metadata": {
                "description": "the time window in seconds for the archival."
            }
        },
        "captureSize": {
            "defaultValue": 314572800,
            "minValue": 10485760,
            "maxValue": 524288000,
            "type": "Int",
            "metadata": {
                "description": "the size window in bytes for the capture."
            }
        },
        "blobContainerName": {
            "type": "String",
            "metadata": {
                "description": "Your existing storage container that you want the blobs archived in."
            }
        },
        "captureNameFormat": {
            "defaultValue": "{Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}",
            "type": "String",
            "metadata": {
                "description": "A Capture Name Format must contain {Namespace}, {EventHub}, {PartitionId}, {Year}, {Month}, {Day}, {Hour}, {Minute} and {Second} fields. These can be arranged in any order with or without delimiters. E.g.  Prod_{EventHub}/{Namespace}\\{PartitionId}_{Year}_{Month}/{Day}/{Hour}/{Minute}/{Second}"
            }
        },
		"existingStgSubId": {
            "type": "String",
            "metadata": {
                "description": "The ID of the Azure subscription that has your existing storage account."
            }
        },
		"existingStgAccRG": {
            "type": "String",
            "metadata": {
                "description": "The resource group that has the storage account."
            }
        },
        "existingStgAcctName": {
            "type": "String",
            "metadata": {
                "description": "The name of the storage account."
            }
        }
    },
    "variables": 
	{
		"roleAssignmentId": "[guid(resourceId('Microsoft.EventHub/namespaces/',parameters('namespaces_eventhubcapture_name')))]",
		"storageBlobDataOwnerId": "[concat(subscription().Id, '/providers/Microsoft.Authorization/roleDefinitions/', 'b7e6dc6d-f1e8-4753-8033-0f276bb0955b')]",
		"ehId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', resourceGroup().name, '/providers/', 'Microsoft.EventHub/namespaces/',parameters('namespaces_eventhubcapture_name')) ]",
		"existingStorageAcctResourceId" : "[concat('/subscriptions/', parameters('existingStgSubId'), '/resourceGroups/', parameters('existingStgAccRG'), '/providers/', 'Microsoft.Storage/storageAccounts/',parameters('existingStgAcctName')) ]"
	},
    "resources": [
        {
            "type": "Microsoft.EventHub/namespaces",
            "apiVersion": "2023-01-01-preview",
            "name": "[parameters('namespaces_eventhubcapture_name')]",
            "location": "eastus",
            "sku": {
                "name": "Standard",
                "tier": "Standard",
                "capacity": 1
            },
            "identity": {
                "type": "SystemAssigned"
            },
            "properties": {
                "minimumTlsVersion": "1.2",
                "publicNetworkAccess": "Enabled",
                "disableLocalAuth": false,
                "zoneRedundant": true,
                "isAutoInflateEnabled": false,
                "maximumThroughputUnits": 0,
                "kafkaEnabled": true
            }
        },
        {
            "type": "Microsoft.EventHub/namespaces/authorizationrules",
            "apiVersion": "2023-01-01-preview",
            "name": "[concat(parameters('namespaces_eventhubcapture_name'), '/RootManageSharedAccessKey')]",
            "location": "eastus",
            "dependsOn": [
                "[resourceId('Microsoft.EventHub/namespaces', parameters('namespaces_eventhubcapture_name'))]"
            ],
            "properties": {
                "rights": [
                    "Listen",
                    "Manage",
                    "Send"
                ]
            }
        },
		{
			"type": "Microsoft.Resources/deployments",
			"apiVersion": "2022-09-01",
			"name": "nestedStgTemplate",
			"subscriptionId": "[parameters('existingStgSubId')]",
			"resourceGroup": "[parameters('existingStgAccRG')]",
			"properties": {
				"expressionEvaluationOptions": {
					"scope": "outer"
				},
				"mode": "Incremental",
				"template": {
					"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
					"contentVersion": "1.0.0.0",
					"resources": [
						{
							"type": "Microsoft.Authorization/roleAssignments",
							"name": "C0F7F914-0FF9-47B2-9960-1D64D97FF594",
							"apiVersion": "2018-01-01-preview",
							"scope": "[variables('existingStorageAcctResourceId')]",
							"properties": {
								"roleDefinitionId": "[variables('storageBlobDataOwnerId')]",
								"principalId": "[reference(variables('ehId'), '2021-11-01', 'Full').identity.principalId]"
							}
						}
					]
				}
			}
		},
        {
            "type": "Microsoft.EventHub/namespaces/eventhubs",
            "apiVersion": "2023-01-01-preview",
            "name": "[concat(parameters('namespaces_eventhubcapture_name'), '/capture')]",
            "location": "eastus",
            "dependsOn": [
                "[resourceId('Microsoft.EventHub/namespaces', parameters('namespaces_eventhubcapture_name'))]",
				"nestedStgTemplate"
            ],
            "properties": {
                "retentionDescription": {
                    "cleanupPolicy": "Delete",
                    "retentionTimeInHours": 24
                },
                "messageRetentionInDays": 1,
                "partitionCount": 1,
                "status": "Active",
                "captureDescription": {
                    "enabled": "[parameters('captureEnabled')]",
                    "skipEmptyArchives": false,
                    "encoding": "[parameters('captureEncodingFormat')]",
                    "intervalInSeconds": "[parameters('captureTime')]",
                    "sizeLimitInBytes": "[parameters('captureSize')]",
                    "destination": {
                        "name": "EventHubArchive.AzureBlockBlob",
                        "properties": {
                            "storageAccountResourceId": "[variables('existingStorageAcctResourceId')]",
                            "blobContainer": "[parameters('blobContainerName')]",
                            "archiveNameFormat": "[parameters('captureNameFormat')]"
                        },
						"identity": {
							"type": "SystemAssigned"
						}
                    }
                }
            }
        },
        {
            "type": "Microsoft.EventHub/namespaces/networkRuleSets",
            "apiVersion": "2023-01-01-preview",
            "name": "[concat(parameters('namespaces_eventhubcapture_name'), '/default')]",
            "location": "eastus",
            "dependsOn": [
                "[resourceId('Microsoft.EventHub/namespaces', parameters('namespaces_eventhubcapture_name'))]"
            ],
            "properties": {
                "publicNetworkAccess": "Enabled",
                "defaultAction": "Allow",
                "virtualNetworkRules": [],
                "ipRules": []
            }
        },
        {
            "type": "Microsoft.EventHub/namespaces/eventhubs/consumergroups",
            "apiVersion": "2023-01-01-preview",
            "name": "[concat(parameters('namespaces_eventhubcapture_name'), '/capture/$Default')]",
            "location": "eastus",
            "dependsOn": [
                "[resourceId('Microsoft.EventHub/namespaces/eventhubs', parameters('namespaces_eventhubcapture_name'), 'capture')]",
                "[resourceId('Microsoft.EventHub/namespaces', parameters('namespaces_eventhubcapture_name'))]"
            ],
            "properties": {}
        }
    ]
}

Parameters.json:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "namespaces_eventhubcapture_name": {
            "value": "NAMESPACENAME"
        },
        "captureEnabled": {
            "value": true
        },
        "captureEncodingFormat": {
            "value": "Avro"
        },
        "captureTime": {
            "value": 300
        },
        "captureSize": {
            "value": 314572800
        },
        "blobContainerName": {
            "value": "BLOBCONTAINERNAME"
        },
        "captureNameFormat": {
            "value": "{Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}"
        },
		"existingStgSubId": {
            "value": "00000000-0000-0000-0000-00000000000000"
        },
		"existingStgAccRG": {
            "value": "STORAGERESOURCEGROUPNAME"
        },
		"existingStgAcctName": {
            "value": "STORAGEACCOUNTNAME"
        }
    }
}

Események rögzítése felhasználó által hozzárendelt felügyelt identitással

Létrehozhat egy felhasználó által hozzárendelt felügyelt identitást, és használhatja hitelesítésre és engedélyezésre az Event Hubs rögzítési célhelyével. A felügyelt identitás létrehozása után hozzárendelheti az Event Hubs-névtérhez, és győződjön meg arról, hogy a rögzítési célhoz engedélyezve van a megfelelő felhasználó által hozzárendelt identitáshoz szükséges szerepkör-hozzárendelés.

Ezután kiválaszthatja User Assigned a felügyelt identitás lehetőséget, amikor engedélyezi a rögzítési funkciót egy eseményközpontban, és hozzárendelheti a szükséges felhasználó által hozzárendelt identitást a rögzítési funkció engedélyezésekor.

Az Event Hubs-adatok Azure Storage-ba vagy Azure Data Lake Storage-ba történő rögzítését bemutató kép Ezután a rögzítési ügynök a konfigurált felhasználó által hozzárendelt identitást használja a hitelesítéshez és az engedélyezéshez a rögzítési célhelyen.

Események rögzítése egy másik előfizetésben lévő rögzítési célhelyre

Az Event Hubs Capture funkció emellett támogatja az adatok rögzítését egy másik előfizetésben lévő rögzítési célhelyre a felügyelt identitás használatával.

Fontos

Az Azure Portal nem támogatja a rögzítési cél kiválasztását egy másik előfizetésből. Ehhez ARM-sablonokat kell használnia.

Ehhez ugyanazokat az ARM-sablonokat használhatja, mint a rögzítés engedélyezéséhez az ARM-sablon útmutatója a megfelelő felügyelt identitással.

Például az alábbi ARM-sablonnal létrehozhat egy eseményközpontot, amelyen engedélyezve van a rögzítés. Az Azure Storage vagy az Azure Data Lake Storage Gen 2 használható rögzítési célként, a felhasználó által hozzárendelt identitás pedig hitelesítési módszerként. A cél erőforrás-azonosítója egy másik előfizetésben lévő erőforrásra mutathat.

"resources":[
      {
         "apiVersion":"[variables('ehVersion')]",
         "name":"[parameters('eventHubNamespaceName')]",
         "type":"Microsoft.EventHub/Namespaces",
         "location":"[variables('location')]",
         "sku":{
            "name":"Standard",
            "tier":"Standard"
         },
         "resources": [
    {
      "apiVersion": "2017-04-01",
      "name": "[parameters('eventHubNamespaceName')]",
      "type": "Microsoft.EventHub/Namespaces",
      "location": "[resourceGroup().location]",
      "sku": {
        "name": "Standard"
      },
      "properties": {
        "isAutoInflateEnabled": "true",
        "maximumThroughputUnits": "7"
      },
      "resources": [
        {
          "apiVersion": "2017-04-01",
          "name": "[parameters('eventHubName')]",
          "type": "EventHubs",
          "dependsOn": [
            "[concat('Microsoft.EventHub/namespaces/', parameters('eventHubNamespaceName'))]"
          ],
          "properties": {
            "messageRetentionInDays": "[parameters('messageRetentionInDays')]",
            "partitionCount": "[parameters('partitionCount')]",
            "captureDescription": {
              "enabled": "true",
              "skipEmptyArchives": false,
              "encoding": "[parameters('captureEncodingFormat')]",
              "intervalInSeconds": "[parameters('captureTime')]",
              "sizeLimitInBytes": "[parameters('captureSize')]",
              "destination": {
                "name": "EventHubArchive.AzureBlockBlob",
                "properties": {
                  "storageAccountResourceId": "[parameters('destinationStorageAccountResourceId')]",
                  "blobContainer": "[parameters('blobContainerName')]",
                  "archiveNameFormat": "[parameters('captureNameFormat')]"
                },
               "identity": {
                 "type": "UserAssigned",
                 "userAssignedIdentities": {
                   "xxxxxxxx": {}
                  }
          						}
              }
            }
          }
        }
      ]
    }
  ]