توصيل Azure Front Door Premium بإدارة واجهة برمجة تطبيقات Azure باستخدام Private Link (معاينة)

ترشدك هذه المقالة خلال خطوات تكوين Azure Front Door Premium للاتصال بشكل خاص بأصل Azure API Management باستخدام Azure Private Link.

المتطلبات الأساسية

إشعار

نوصي باستخدام الوحدة النمطية Azure Az PowerShell للتفاعل مع Azure. للبدء، راجع تثبيت Azure PowerShell. لمعرفة كيفية الترحيل إلى الوحدة النمطية Az PowerShell، راجع ترحيل Azure PowerShell من AzureRM إلى Az.

Azure Cloud Shell

Azure يستضيف Azure Cloud Shell، بيئة تفاعلية يمكن استخدامها من خلال المستعرض. يمكنك استخدام Bash أو PowerShell مع Cloud Shell للعمل مع خدمات Azure. يمكنك استخدام أوامر Cloud Shell المثبتة مسبقًا لتشغيل التعليمات البرمجية في هذه المقالة دون الحاجة إلى تثبيت أي شيء على البيئة المحلية.

لبدء Azure Cloud Shell:

خيار مثال/ رابط
انقر فوق ⁧⁩جربه⁧⁩ في الزاوية العلوية اليسرى من التعليمة البرمجية أو كتلة الأمر. تحديد ⁧⁩جربه⁧⁩ لا يقوم بنسخ التعليمة البرمجية أو الأمر تلقائيًا إلى Cloud Shell. لقطة شاشة تعرض مثالاً على Try It for Azure Cloud Shell.
انتقل إلى ⁧⁩⁧ https://shell.azure.com⁩⁧⁩، أو حدد زر ⁩تشغيل Cloud Shell لفتح Cloud Shell في المتصفح لديك. زر لتشغيل Azure Cloud Shell.
حدد زر Cloud Shell على شريط القوائم في أعلى اليمين في مدخل Microsoft Azure. لقطة شاشة تعرض زر Cloud Shell في مدخل Microsoft Azure

لاستخدام Azure Cloud Shell:

  1. ابدأ تشغيل Cloud Shell.

  2. حدد الزر نسخ على كتلة التعليمات البرمجية (أو كتلة الأوامر) لنسخ التعليمات البرمجية أو الأمر.

  3. ألصق التعليمة البرمجية أو الأمر في جلسة Cloud Shell بتحديد Ctrl+Shift+Vعلى Windows وLunix، أو بتحديد Cmd+Shift+Vعلى macOS.

  4. حدد Enter لتشغيل التعليمات البرمجية أو الأمر.

إنشاء مجموعة أصل وإضافة مثيل APIM كأصل

  1. استخدم New-AzFrontDoorCdnOriginGroupHealthProbeSettingObject لإنشاء كائن في الذاكرة لتخزين إعدادات فحص السلامة.

    $healthProbeSetting = New-AzFrontDoorCdnOriginGroupHealthProbeSettingObject `
        -ProbeIntervalInSecond 60 `
        -ProbePath "/" `
        -ProbeRequestType GET `
        -ProbeProtocol Http
    
  2. استخدم New-AzFrontDoorCdnOriginGroupLoadBalancingSettingObject لإنشاء كائن في الذاكرة لتخزين إعدادات موازنة التحميل.

    $loadBalancingSetting = New-AzFrontDoorCdnOriginGroupLoadBalancingSettingObject `
        -AdditionalLatencyInMillisecond 50 `
        -SampleSize 4 `
        -SuccessfulSamplesRequired 3
    
  3. قم بتشغيل New-AzFrontDoorCdnOriginGroup لإنشاء مجموعة أصل تحتوي على مثيل APIM الخاص بك.

    $origingroup = New-AzFrontDoorCdnOriginGroup `
        -OriginGroupName myOriginGroup `
        -ProfileName myFrontDoorProfile `
        -ResourceGroupName myResourceGroup `
        -HealthProbeSetting $healthProbeSetting `
        -LoadBalancingSetting $loadBalancingSetting
    
  4. استخدم الأمر New-AzFrontDoorCdnOrigin لإضافة مثيل APIM إلى مجموعة الأصل.

    New-AzFrontDoorCdnOrigin ` 
        -OriginGroupName myOriginGroup ` 
        -OriginName myAPIMOrigin ` 
        -ProfileName myFrontDoorProfile ` 
        -ResourceGroupName myResourceGroup ` 
        -HostName myapim.azure-api.net ` 
        -HttpPort 80 ` 
        -HttpsPort 443 ` 
        -OriginHostHeader myapim.azure-api.net ` 
        -Priority 1 ` 
        -PrivateLinkId /subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/myResourceGroup/providers/Microsoft.ApiManagement/service/myAPIM ` 
        -SharedPrivateLinkResourceGroupId Gateway ` 
        -SharedPrivateLinkResourcePrivateLinkLocation CentralUS ` 
        -SharedPrivateLinkResourceRequestMessage 'Azure Front Door private connectivity request' ` 
        -Weight 1000 `
    

الموافقة على نقطة النهاية الخاصة

  1. قم بتشغيل Get-AzPrivateEndpointConnection لاسترداد اسم الاتصال لاتصال نقطة النهاية الخاصة التي تحتاج إلى الموافقة.

    $PrivateEndpoint = Get-AzPrivateEndpointConnection -ResourceGroupName myResourceGroup -ServiceName myAPIM -PrivateLinkResourceType Microsoft.ApiManagement/service
    
  2. قم بتشغيل Approve-AzPrivateEndpointConnection للموافقة على تفاصيل اتصال نقطة النهاية الخاصة. استخدم قيمة الاسم من الإخراج في الخطوة السابقة للموافقة على الاتصال.

    Get-AzPrivateEndpointConnection -Name $PrivateEndpoint.Name -ResourceGroupName myResourceGroup -ServiceName myAPIM -PrivateLinkResourceType Microsoft.ApiManagement/service
    

إكمال إعداد Azure Front Door

استخدم الأمر New-AzFrontDoorCdnRoute لإنشاء مسار يعين نقطة النهاية إلى مجموعة الأصل. يقوم هذا المسار بإعادة توجيه الطلبات من نقطة النهاية إلى مجموعة الأصل الخاصة بك.

# Create a route to map the endpoint to the origin group

$Route = New-AzFrontDoorCdnRoute `
    -EndpointName myFrontDoorEndpoint `
    -Name myRoute `
    -ProfileName myFrontDoorProfile `
    -ResourceGroupName myResourceGroup `
    -ForwardingProtocol MatchRequest `
    -HttpsRedirect Enabled `
    -LinkToDefaultDomain Enabled `
    -OriginGroupId $origingroup.Id `
    -SupportedProtocol Http,Https

يعمل ملف تعريف Azure Front Door الآن بكامل طاقته بعد إكمال الخطوة الأخيرة.

المتطلبات الأساسية

إنشاء مجموعة أصل وإضافة مثيل APIM كأصل

  1. قم بتشغيل az afd origin-group create لإنشاء مجموعة أصل.

    az afd origin-group create \
        --resource-group myResourceGroup \
        --origin-group-name myOriginGroup \
        --profile-name myFrontDoorProfile \
        --probe-request-type GET \
        --probe-protocol Http \
        --probe-interval-in-seconds 60 \
        --probe-path / \
        --sample-size 4 \
        --successful-samples-required 3 \
        --additional-latency-in-milliseconds 50
    
  2. قم بتشغيل az afd origin create لإضافة مثيل APIM كأصل إلى مجموعة الأصل.

    az afd origin create \
        --enabled-state Enabled \
        --resource-group myResourceGroup \
        --origin-group-name myOriginGroup \
        --origin-name myAPIMOrigin \
        --profile-name myFrontDoorProfile \
        --host-name myapim.azure-api.net \
        --origin-host-header myapim.azure-api.net \
        --http-port 80  \
        --https-port 443 \
        --priority 1 \
        --weight 500 \
        --enable-private-link true \
        --private-link-location centralus \
        --private-link-request-message 'Azure Front Door private connectivity request.' \
        --private-link-resource /subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/myResourceGroup/providers/Microsoft.ApiManagement/service/myAPIM \
        --private-link-sub-resource-type Gateway
    

الموافقة على اتصال نقطة النهاية الخاصة

  1. قم بتشغيل az network private-endpoint-connection list للحصول على اسم اتصال نقطة النهاية الخاصة التي تحتاج إلى الموافقة.

    az network private-endpoint-connection list --name myAPIM --resource-group myResourceGroup --type Microsoft.ApiManagement/service
    
  2. قم بتشغيل az network private-endpoint-connection approve to approve the private endpoint connection using the name from the previous step.

    az network private-endpoint-connection approve --id /subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/myResourceGroup/providers/Microsoft.ApiManagement/service/myAPIM/privateEndpointConnections/aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb
    

إكمال إعداد Azure Front Door

قم بتشغيل az afd route create لإنشاء مسار يقوم بتعيين نقطة النهاية الخاصة بك إلى مجموعة الأصل. يقوم هذا المسار بإعادة توجيه الطلبات من نقطة النهاية إلى مجموعة الأصل الخاصة بك.

az afd route create \
    --resource-group myResourceGroup \
    --profile-name myFrontDoorProfile \
    --endpoint-name myFrontDoorEndpoint \
    --forwarding-protocol MatchRequest \
    --route-name myRoute \
    --https-redirect Enabled \
    --origin-group myOriginGroup \
    --supported-protocols Http Https \
    --link-to-default-domain Enabled

يعمل ملف تعريف Azure Front Door الآن بكامل طاقته بعد إكمال الخطوة الأخيرة.

الخطوات التالية

تعرف على خدمة Private Link مع حساب تخزين.