Notitie
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen u aan te melden of de directory te wijzigen.
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen de mappen te wijzigen.
Aan de slag met een Private Link-service die naar uw service verwijst. Geef Private Link toegang tot uw service of resource die achter een Azure Standard Load Balancer is geïmplementeerd. Gebruikers van uw service hebben persoonlijke toegang via hun virtuele netwerk.
Vereiste voorwaarden
Een Azure-account met een actief abonnement. Gratis een account maken
Azure Cloud Shell or Azure PowerShell.
Met de stappen in deze quickstart worden de Azure PowerShell-cmdlets interactief uitgevoerd in Azure Cloud Shell. Als u de opdrachten in Cloud Shell wilt uitvoeren, selecteert u CloudShell openen in de rechterbovenhoek van een codeblok. Selecteer Kopiëren om de code te kopiëren en plak deze in Cloud Shell om deze uit te voeren. U kunt Cloud Shell ook uitvoeren vanuit Azure Portal.
U kunt Azure PowerShell ook lokaal installeren om de cmdlets uit te voeren. Voor de stappen in dit artikel is Azure PowerShell-moduleversie 5.4.1 of hoger vereist. Voer deze opdracht
Get-Module -ListAvailable Az
uit om uw geïnstalleerde versie te vinden. Zie De Azure PowerShell-module bijwerken als u een upgrade moet uitvoeren.Als u PowerShell lokaal uitvoert, voert u deze uit
Connect-AzAccount
om verbinding te maken met Azure.
Een brongroep maken
Een Azure-resourcegroep is een logische container waarin Azure-resources worden geïmplementeerd en beheerd.
Maak een resourcegroep met New-AzResourceGroup:
New-AzResourceGroup -Name 'test-rg' -Location 'eastus2'
Een interne load balancer maken
In deze sectie maakt u een virtueel netwerk en een interne Azure Load Balancer.
Virtueel netwerk
In deze sectie maakt u een virtueel netwerk en subnet om de load balancer te hosten die toegang heeft tot uw Private Link-service.
- Maak een virtueel netwerk met 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
Een standard load balancer maken
In deze sectie wordt beschreven hoe u de volgende onderdelen van de load balancer kunt maken en configureren.
Maak een front-end-IP met New-AzLoadBalancerFrontendIpConfig voor de front-end-IP-pool. Dit IP-adres ontvangt het binnenkomende verkeer op de load balancer
Maak een back-endadresgroep met New-AzLoadBalancerBackendAddressPoolConfig voor verkeer dat wordt verzonden vanaf de front-end van de load balancer. In deze pool worden uw virtuele back-endmachines geïmplementeerd.
Maak een statustest met Add-AzLoadBalancerProbeConfig die de status van de back-end-VM-exemplaren bepaalt.
Maak een load balancer-regel met Add-AzLoadBalancerRuleConfig waarmee wordt gedefinieerd hoe verkeer naar de VIRTUELE machines wordt gedistribueerd.
Maak een openbare load balancer met 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
Netwerkbeleid uitschakelen
Voordat een private link-service kan worden gemaakt in het virtuele netwerk, moet de instelling privateLinkServiceNetworkPolicies
worden uitgeschakeld.
- Schakel het netwerkbeleid uit met 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
Een Private Link-service maken
In deze sectie maakt u een private link-service die gebruikmaakt van de Standard Azure Load Balancer die in de vorige stap is gemaakt.
Maak de IP-configuratie van de Private Link Service met New-AzPrivateLinkServiceIpConfig.
Maak de private link-service met New-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
Uw Private Link-service wordt gemaakt en kan verkeer ontvangen. Als u verkeersstromen wilt zien, configureert u uw toepassing achter uw standaard load balancer.
Privé-eindpunt maken
In deze sectie wijst u de private link-service toe aan een privé-eindpunt. Een virtueel netwerk bevat het privé-eindpunt voor de private link-service. Dit virtuele netwerk bevat de resources die toegang hebben tot uw Private Link-service.
Privé-eindpunt virtueel netwerk maken
- Maak een virtueel netwerk met 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
Eindpunt en verbinding maken
Gebruik Get-AzPrivateLinkService om de configuratie van de private link-service die u vroeg in een variabele hebt gemaakt te plaatsen voor later gebruik.
Gebruik New-AzPrivateLinkServiceConnection om de verbindingsconfiguratie te maken.
Gebruik New-AzPrivateEndpoint om het eindpunt te maken.
## 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
De privé-eindpuntverbinding goedkeuren
In deze sectie keurt u de verbinding goed die u in de vorige stappen hebt gemaakt.
- Gebruik Approve-AzPrivateEndpointConnection om de verbinding goed te keuren.
## 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-adres van privé-eindpunt
In deze sectie vindt u het IP-adres van het privé-eindpunt dat overeenkomt met de load balancer- en private link-service.
- Gebruik Get-AzPrivateEndpoint om het IP-adres op te halen.
## 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
Hulpmiddelen opruimen
U kunt de opdracht Remove-AzResourceGroup gebruiken om de resourcegroep, de load balancer en de resterende resources te verwijderen wanneer u deze niet meer nodig hebt.
Remove-AzResourceGroup -Name 'test-rg'
Volgende stappen
In deze snelstart, gaat u het volgende doen:
Een virtueel netwerk gemaakt en een interne Azure Load Balancer.
Een private link-service gemaakt
Voor meer informatie over Azure Privé-eindpunt gaat u naar: