Konfigurowanie zasad punktu końcowego usługi sieci wirtualnej dla usługi Azure HDInsight

Ten artykuł zawiera informacje o sposobie implementowania zasad punktu końcowego usługi w sieciach wirtualnych za pomocą usługi Azure HDInsight.

Tło

Usługa Azure HDInsight umożliwia tworzenie klastrów w własnej sieci wirtualnej. Jeśli musisz zezwolić na ruch wychodzący z sieci wirtualnej do innych usług platformy Azure, takich jak konta magazynu, możesz utworzyć zasady punktu końcowego usługi. Zasady punktu końcowego usługi utworzone za pośrednictwem Azure Portal umożliwiają jednak utworzenie zasad tylko dla jednego konta, wszystkich kont w subskrypcji lub wszystkich kont w grupie zasobów.

Jako usługa zarządzana usługa Azure HDInsight zbiera jednak dane i pliki dziennika z każdego klastra na określonych kontach magazynu w każdym regionie. Aby te dane dotarły do usługi HDInsight z sieci wirtualnej, należy utworzyć zasady punktu końcowego usługi, które zezwalają na ruch wychodzący do określonych punktów zbierania danych zarządzanych przez usługę Azure HDInsight.

Zasady punktu końcowego usługi dla usługi HDInsight

Te zasady punktu końcowego usługi obsługują następujące funkcje:

  • Zbieranie dzienników i danych telemetrycznych dotyczących tworzenia klastra, wykonywania zadań i operacji platformy, takich jak skalowanie.
  • Dołączanie wirtualnych dysków twardych (VHD) do nowo utworzonych węzłów klastra na potrzeby aprowizowania oprogramowania i bibliotek w klastrze.

Jeśli zasady punktu końcowego usługi nie zostaną utworzone w celu włączenia tego przepływu danych, tworzenie klastra może zakończyć się niepowodzeniem, a usługa Azure HDInsight nie będzie mogła zapewnić obsługi klastrów.

Tworzenie zasad punktu końcowego usługi dla usługi HDInsight

Przed utworzeniem nowych klastrów upewnij się, że prawidłowe zasady punktu końcowego usługi są dołączone do sieci wirtualnej. W przeciwnym razie tworzenie klastra może zakończyć się niepowodzeniem lub spowodować błąd.

Użyj następującego procesu, aby utworzyć niezbędne zasady punktu końcowego usługi:

  1. Zdecyduj, w którym regionie utworzysz klaster usługi HDInsight.

  2. Wyszukaj ten region na liście zasobów zasad punktu końcowego usługi, co daje wszystkie grupy zasobów dla kont magazynu zarządzania usługi HDInsight.

  3. Wybierz listę grup zasobów dla swojego regionu. Poniżej przedstawiono przykład zasobów Canada Central :

    "Canada Central":[
        "/subscriptions/235d341f-7fb9-435c-9bdc-034b7306c9b4/resourceGroups/Default-Storage-WestUS",
        "/subscriptions/da0c4c68-9283-4f88-9c35-18f7bd72fbdd/resourceGroups/GenevaWarmPathManageRG",
        "/subscriptions/6a853a41-3423-4167-8d9c-bcf37dc72818/resourceGroups/GenevaWarmPathManageRG",
        "/subscriptions/c8845df8-14d1-4a46-b6dd-e0c44ae400b0/resourceGroups/Default-Storage-CanadaCentral",
        "/subscriptions/c8845df8-14d1-4a46-b6dd-e0c44ae400b0/resourceGroups/cancstorage",
        "/subscriptions/c8845df8-14d1-4a46-b6dd-e0c44ae400b0/resourceGroups/GenevaWarmPathManageRG",
        "/subscriptions/fb3429ab-83d0-4bed-95e9-1a8e9455252c/resourceGroups/DistroStorageRG/providers/Microsoft.Storage/storageAccounts/hdi31distrorelease",
        "/subscriptions/fb3429ab-83d0-4bed-95e9-1a8e9455252c/resourceGroups/DistroStorageRG/providers/Microsoft.Storage/storageAccounts/bigdatadistro"
    ],
    
  4. Wstaw listę grup zasobów do skryptu instalacji napisanego w interfejsie wiersza polecenia platformy Azure lub Azure PowerShell.

    $subscriptionId = "<subscription id>"
    $rgName="<resource group name> "
    $location="<location name>"
    $vnetName="<vnet name>"
    $subnetName="<subnet name>"
    $sepName="<service endpoint policy name>"
    $sepDefName="<service endpoint policy definition name>"
    
    # Set to the right subscription ID
    az account set --subscription $subscriptionId
    
    # setup service endpoint on the virtual network subnet
    az network vnet subnet update -g $rgName --vnet-name $vnetName -n $subnetName --service-endpoints Microsoft.Storage
    
    # Create Service Endpoint Policy
    az network service-endpoint policy create -g $rgName  -n $sepName -l $location
    
    # Insert the list of HDInsight owned resources for the region your clusters will be created in.
    # Be sure to get the most recent list of resource groups from the [list of service endpoint policy resources](https://github.com/Azure-Samples/hdinsight-enterprise-security/blob/main/hdinsight-service-endpoint-policy-resources.json)
    [String[]]$resources = @("/subscriptions/235d341f-7fb9-435c-9bdc-034b7306c9b4/resourceGroups/Default-Storage-WestUS",`
    "/subscriptions/da0c4c68-9283-4f88-9c35-18f7bd72fbdd/resourceGroups/GenevaWarmPathManageRG",`
    "/subscriptions/6a853a41-3423-4167-8d9c-bcf37dc72818/resourceGroups/GenevaWarmPathManageRG",`
    "/subscriptions/c8845df8-14d1-4a46-b6dd-e0c44ae400b0/resourceGroups/Default-Storage-CanadaCentral",`
    "/subscriptions/c8845df8-14d1-4a46-b6dd-e0c44ae400b0/resourceGroups/cancstorage",`
    "/subscriptions/c8845df8-14d1-4a46-b6dd-e0c44ae400b0/resourceGroups/GenevaWarmPathManageRG",
    "/subscriptions/fb3429ab-83d0-4bed-95e9-1a8e9455252c/resourceGroups/DistroStorageRG/providers/Microsoft.Storage/storageAccounts/hdi31distrorelease",
    "/subscriptions/fb3429ab-83d0-4bed-95e9-1a8e9455252c/resourceGroups/DistroStorageRG/providers/Microsoft.Storage/storageAccounts/bigdatadistro")
    
    #Assign service resources to the SEP policy.
    az network service-endpoint policy-definition create -g $rgName --policy-name $sepName -n $sepDefName --service "Microsoft.Storage" --service-resources $resources
    
    # Associate a subnet to the service endpoint policy just created. If there is a delay in updating it to subnet, you can use the Azure portal to associate the policy with the subnet.
    az network vnet subnet update -g $rgName --vnet-name $vnetName -n $subnetName --service-endpoint-policy $sepName
    

    Jeśli wolisz skonfigurować zasady punktu końcowego usługi przy użyciu programu PowerShell, użyj poniższego fragmentu kodu.

    #Script to assign SEP 
    $subscriptionId = "<subscription id>"
    $rgName = "<resource group name>"
    $vnetName = "<vnet name>"
    $subnetName = "<subnet Name"
    $location = "Canada Central"
    
    # Connect to your Azure Account
    Connect-AzAccount
    
    # Select the Subscription that you want to use
    Select-AzSubscription -SubscriptionId $subscriptionId
    
    # Retrieve VNet Config
    $vnet = Get-AzVirtualNetwork -ResourceGroupName $rgName -Name $vnetName
    
    # Retrieve Subnet Config
    $subnet = Get-AzVirtualNetworkSubnetConfig -Name $subnetName -VirtualNetwork $vnet
    
    # Insert the list of HDInsight owned resources for the region your clusters will be created in.
    # Be sure to get the most recent list of resource groups from the [list of service endpoint policy resources](https://github.com/Azure-Samples/hdinsight-enterprise-security/blob/main/hdinsight-service-endpoint-policy-resources.json)
    [String[]]$resources = @("/subscriptions/235d341f-7fb9-435c-9bdc-034b7306c9b4/resourceGroups/Default-Storage-WestUS",
    "/subscriptions/da0c4c68-9283-4f88-9c35-18f7bd72fbdd/resourceGroups/GenevaWarmPathManageRG",
    "/subscriptions/6a853a41-3423-4167-8d9c-bcf37dc72818/resourceGroups/GenevaWarmPathManageRG",
    "/subscriptions/c8845df8-14d1-4a46-b6dd-e0c44ae400b0/resourceGroups/Default-Storage-CanadaCentral",
    "/subscriptions/c8845df8-14d1-4a46-b6dd-e0c44ae400b0/resourceGroups/cancstorage",
    "/subscriptions/c8845df8-14d1-4a46-b6dd-e0c44ae400b0/resourceGroups/GenevaWarmPathManageRG",
    "/subscriptions/fb3429ab-83d0-4bed-95e9-1a8e9455252c/resourceGroups/DistroStorageRG/providers/Microsoft.Storage/storageAccounts/hdi31distrorelease",
    "/subscriptions/fb3429ab-83d0-4bed-95e9-1a8e9455252c/resourceGroups/DistroStorageRG/providers/Microsoft.Storage/storageAccounts/bigdatadistro")
    
    #Declare service endpoint policy definition
    $sepDef = New-AzServiceEndpointPolicyDefinition -Name "SEPHDICanadaCentral" -Description "Service Endpoint Policy Definition" -Service "Microsoft.Storage" -ServiceResource $resources
    
    # Service Endpoint Policy
    $sep= New-AzServiceEndpointPolicy -ResourceGroupName $rgName -Name "SEPHDICanadaCentral" -Location $location -ServiceEndpointPolicyDefinition $sepDef
    
    # Associate a subnet to the service endpoint policy just created. If there is a delay in updating it to subnet, you can use the Azure portal to associate the policy with the subnet.
    Set-AzVirtualNetworkSubnetConfig -Name $subnetName -VirtualNetwork $vnet -AddressPrefix $subnet.AddressPrefix -ServiceEndpointPolicy $sep
    

Ważne

Zaleca się pobranie najnowszej listy zasobów zasad punktu końcowego usługi zgodnie z harmonogramem ręcznie lub za pośrednictwem automatyzacji. Zapobiega to problemom CRUD podczas dodawania lub usuwania dodatkowych grup zasobów z pliku JSON.

Następne kroki