التشغيل السريع: إنشاء خدمة رابط خاص باستخدام Azure PowerShell
ابدأ بإنشاء خدمة رابط خاص تشير إلى الخدمة الخاصة بكم. منح وصول الارتباط الخاص إلى الخدمة أو المورد المنتشر خلف Azure Standard Load Balancer. مستخدمو الخدمة الخاصة بك لديهم إمكانية الوصول الخاص من الشبكة الافتراضية الخاصة بهم.
المتطلبات الأساسية
حساب Azure باشتراك نشط. إنشاء حساب مجاناً.
Azure Cloud Shell أو Azure PowerShell.
تعمل الخطوات الواردة في هذا التشغيل السريع على تشغيل أوامر Cmdlets Azure PowerShell بشكل تفاعلي في Azure Cloud Shell. لتشغيل الأوامر في Cloud Shell، حدد Open Cloudshell في الزاوية العلوية اليسرى من كتلة التعليمات البرمجية. حدد نسخ لنسخ التعليمات البرمجية ثم لصقها في Cloud Shell لتشغيلها. يمكنك أيضا تشغيل Cloud Shell من داخل مدخل Microsoft Azure.
يمكنك أيضا تثبيت Azure PowerShell محليا لتشغيل أوامر cmdlets. تتطلب الخطوات الواردة في هذه المقالة إصدار الوحدة النمطية Azure PowerShell 5.4.1 أو أحدث. للعثور على الإصدار المثبت، قم بتشغيل
Get-Module -ListAvailable Az
. إذا كنت بحاجة إلى الترقية، فشاهد تحديث الوحدة النمطية Azure PowerShell.إذا قمت بتشغيل PowerShell محليا، فقم بتشغيل
Connect-AzAccount
للاتصال ب Azure.
قم بإنشاء مجموعة موارد
مجموعة موارد Azure هي حاوية منطقية يتم بها نشر موارد Azure وإدارتها.
إنشاء مجموعة موارد باستخدام New AzResourceGroup:
New-AzResourceGroup -Name 'test-rg' -Location 'eastus2'
إنشاء موازن التحميل الداخلي
في هذا القسم، يمكنك إنشاء شبكة ظاهرية وموازن تحميل Azure داخلي.
شبكة ظاهرية
في هذا المقطع، ستقومون بإنشاء شبكة اتصال ظاهرية وشبكة فرعية؛ لاستضافة موازن التحميل الذي يصل إلى خدمة الارتباط الخاص بكم.
- أنشئ شبكة ظاهرية باستخدام New-AzVirtualNetwork.
## Create backend subnet config ##
$subnet = @{
Name = 'subnet-1'
AddressPrefix = '10.0.0.0/24'
}
$subnetConfig = New-AzVirtualNetworkSubnetConfig @subnet
## Create the virtual network ##
$net = @{
Name = 'vnet-1'
ResourceGroupName = 'test-rg'
Location = 'eastus2'
AddressPrefix = '10.0.0.0/16'
Subnet = $subnetConfig
}
$vnet = New-AzVirtualNetwork @net
إنشاء موازن تحميل قياسي
يوضح هذا القسم بالتفصيل كيفية إنشاء المكونات التالية من موازن التحميل وتكوينها:
قوموا بإنشاء عنوان IP للواجهة الأمامية باستخدام New-AzLoadBalancerFrontendIpConfig لتجمع IP للواجهة الأمامية. يتلقى عنوان IP هذا حركة المرور الواردة على موازن التحميل
قوموا بإنشاء مجموعة عناوين خلفية باستخدام New-AzLoadBalancerBackendAddressPoolConfig لحركة المرور المرسلة من الواجهة الأمامية لموازنة التحميل. هذا التجمع حيث يتم نشر الأجهزة الظاهرية الخلفية.
قوموا بإنشاء اختبار صحة باستخدام Add-AzLoadBalancerProbeConfig الذي يحدد صحة مثيلات VM الخلفية.
قوموا بإنشاء قاعدة موازن التحميل باستخدام Add-AzLoadBalancerRuleConfig التي تحدد كيفية توزيع حركة المرور على الأجهزة الظاهرية.
قم بإنشاء موازن تحميل عامًا باستخدام New-AzLoadBalancer.
## Place virtual network created in previous step into a variable. ##
$vnet = Get-AzVirtualNetwork -Name 'vnet-1' -ResourceGroupName 'test-rg'
## Create load balancer frontend configuration and place in variable. ##
$lbip = @{
Name = 'frontend'
PrivateIpAddress = '10.0.0.4'
SubnetId = $vnet.subnets[0].Id
}
$feip = New-AzLoadBalancerFrontendIpConfig @lbip
## Create backend address pool configuration and place in variable. ##
$bepool = New-AzLoadBalancerBackendAddressPoolConfig -Name 'backend-pool'
## Create the health probe and place in variable. ##
$probe = @{
Name = 'health-probe'
Protocol = 'http'
Port = '80'
IntervalInSeconds = '360'
ProbeCount = '5'
RequestPath = '/'
}
$healthprobe = New-AzLoadBalancerProbeConfig @probe
## Create the load balancer rule and place in variable. ##
$lbrule = @{
Name = 'http-rule'
Protocol = 'tcp'
FrontendPort = '80'
BackendPort = '80'
IdleTimeoutInMinutes = '15'
FrontendIpConfiguration = $feip
BackendAddressPool = $bePool
}
$rule = New-AzLoadBalancerRuleConfig @lbrule -EnableTcpReset
## Create the load balancer resource. ##
$loadbalancer = @{
ResourceGroupName = 'test-rg'
Name = 'load-balancer'
Location = 'eastus2'
Sku = 'Standard'
FrontendIpConfiguration = $feip
BackendAddressPool = $bePool
LoadBalancingRule = $rule
Probe = $healthprobe
}
New-AzLoadBalancer @loadbalancer
تعطيل نهج الشبكة
قبل إنشاء خدمة ارتباط خاص في الشبكة الظاهرية، يجب تعطيل الإعداد privateLinkServiceNetworkPolicies
.
- تعطيل نهج الشبكة باستخدام Set-AzVirtualNetwork.
## Place the subnet name into a variable. ##
$subnet = 'subnet-1'
## Place the virtual network configuration into a variable. ##
$net = @{
Name = 'vnet-1'
ResourceGroupName = 'test-rg'
}
$vnet = Get-AzVirtualNetwork @net
## Set the policy as disabled on the virtual network. ##
($vnet | Select -ExpandProperty subnets | Where-Object {$_.Name -eq $subnet}).privateLinkServiceNetworkPolicies = "Disabled"
## Save the configuration changes to the virtual network. ##
$vnet | Set-AzVirtualNetwork
إنشاء خدمة رابط خاص
في هذا المقطع، إنشاء خدمة رابط خاص يستخدم موازن تحميل Azure القياسية التي تم إنشاؤها في الخطوة السابقة.
إنشاء تكوين IP خدمة الارتباط الخاص مع جديد AzPrivateLinkServiceIpConfig.
إنشاء خدمة الارتباط الخاص مع جديد AzPrivateLinkService.
## Place the virtual network into a variable. ##
$vnet = Get-AzVirtualNetwork -Name 'vnet-1' -ResourceGroupName 'test-rg'
## Create the IP configuration for the private link service. ##
$ipsettings = @{
Name = 'ipconfig-1'
PrivateIpAddress = '10.0.0.5'
Subnet = $vnet.subnets[0]
}
$ipconfig = New-AzPrivateLinkServiceIpConfig @ipsettings
## Place the load balancer frontend configuration into a variable. ##
$par = @{
Name = 'load-balancer'
ResourceGroupName = 'test-rg'
}
$fe = Get-AzLoadBalancer @par | Get-AzLoadBalancerFrontendIpConfig
## Create the private link service for the load balancer. ##
$privlinksettings = @{
Name = 'private-link-service'
ResourceGroupName = 'test-rg'
Location = 'eastus2'
LoadBalancerFrontendIpConfiguration = $fe
IpConfiguration = $ipconfig
}
New-AzPrivateLinkService @privlinksettings
يتم إنشاء خدمة الارتباط الخاص بكم، ويمكن أن تتلقى حركة المرور. إذا كنتم تريدون مشاهدة تدفق حركة المرور، فقم بتكوين التطبيق خلف موازن التحميل القياسي.
إنشاء نقطة نهاية خاصة
في هذا القسم، يمكنك تعيين خدمة الارتباط الخاص إلى نقطة نهاية خاصة. شبكة ظاهرية تحتوي على نقطة النهاية الخاصة لخدمة الارتباط الخاص. تحتوي هذه الشبكة الظاهرية على الموارد التي تصل إلى خدمة الارتباط الخاص بك.
إنشاء شبكة اتصال ظاهرية خاصة بنقطة النهاية
- أنشئ شبكة ظاهرية باستخدام New-AzVirtualNetwork.
## Create backend subnet config ##
$subnet = @{
Name = 'subnet-pe'
AddressPrefix = '10.1.0.0/24'
}
$subnetConfig = New-AzVirtualNetworkSubnetConfig @subnet
## Create the virtual network ##
$net = @{
Name = 'vnet-pe'
ResourceGroupName = 'test-rg'
Location = 'eastus2'
AddressPrefix = '10.1.0.0/16'
Subnet = $subnetConfig
}
$vnetpe = New-AzVirtualNetwork @net
إنشاء نقطة النهاية والاتصال
استخدم Get-AzPrivateLinkService لوضع تكوين خدمة الارتباطات الخاصة التي قمت بإنشائها مبكرًا في متغير للاستخدام لاحقًا.
استخدمجديد AzPrivateLinkServiceConnection لإنشاء تكوين الاتصال.
استخدم New-AzPrivateEndpointلإنشاء نقطة نهاية.
## Place the private link service configuration into variable. ##
$par1 = @{
Name = 'private-link-service'
ResourceGroupName = 'test-rg'
}
$pls = Get-AzPrivateLinkService @par1
## Create the private link configuration and place in variable. ##
$par2 = @{
Name = 'connection-1'
PrivateLinkServiceId = $pls.Id
}
$plsConnection = New-AzPrivateLinkServiceConnection @par2
## Place the virtual network into a variable. ##
$par3 = @{
Name = 'vnet-pe'
ResourceGroupName = 'test-rg'
}
$vnetpe = Get-AzVirtualNetwork @par3
## Create private endpoint ##
$par4 = @{
Name = 'private-endpoint'
ResourceGroupName = 'test-rg'
Location = 'eastus2'
Subnet = $vnetpe.subnets[0]
PrivateLinkServiceConnection = $plsConnection
}
New-AzPrivateEndpoint @par4 -ByManualRequest
الموافقة على اتصال نقطة النهاية الخاصة
في هذا القسم، يمكنك الموافقة على الاتصال الذي أنشأته في الخطوات السابقة.
- استخدم الموافقة-AzPrivateEndpointConnection للموافقة على الاتصال.
## Place the private link service configuration into variable. ##
$par1 = @{
Name = 'private-link-service'
ResourceGroupName = 'test-rg'
}
$pls = Get-AzPrivateLinkService @par1
$par2 = @{
Name = $pls.PrivateEndpointConnections[0].Name
ServiceName = 'private-link-service'
ResourceGroupName = 'test-rg'
Description = 'Approved'
PrivateLinkResourceType = 'Microsoft.Network/privateLinkServices'
}
Approve-AzPrivateEndpointConnection @par2
عنوان IP لنقطة النهاية الخاصة
في هذا القسم، يمكنك العثور على عنوان IP لنقطة النهاية الخاصة التي تتوافق مع موازن التحميل وخدمة الارتباط الخاص.
- استخدم Get-AzPrivateEndpoint لاسترداد عنوان IP.
## Get private endpoint and the IP address and place in a variable for display. ##
$par1 = @{
Name = 'private-endpoint'
ResourceGroupName = 'test-rg'
ExpandResource = 'networkinterfaces'
}
$pe = Get-AzPrivateEndpoint @par1
## Display the IP address by expanding the variable. ##
$pe.NetworkInterfaces[0].IpConfigurations[0].PrivateIpAddress
❯ $pe.NetworkInterfaces[0].IpConfigurations[0].PrivateIpAddress
10.1.0.4
تنظيف الموارد
عند انتهاء الحاجة إليها، يمكنك استخدام الأمر Remove-AzResourceGroupلإزالة مجموعة الموارد، وموزان التحميل، وجميع الموارد ذات الصلة.
Remove-AzResourceGroup -Name 'test-rg'
الخطوات التالية
في هذه البداية السريعة، تمكنت من:
إنشاء شبكة ظاهرية وموازن تحميل Azure داخلي.
إنشاء خدمة رابط خاص
لمعرفة المزيد حول نقطة النهاية الخاصة بـ Azure، تابع ما يلي: