问题
I've got an FTP server running on Azure. I had to manually add in 20 endpoints for the 'data' connection.
It was painful.
Surely there's a better way to bulk add endpoints to an Azure VM, somehow? If so, could someone list some instructions? I'm open to anything.
eg. I would love to create
TCP public port 61020 - private port 61020
to
TCP public port 61100 - private port 61100
hmmm....
回答1:
You can do this with PowerShell. A just tested script:
Add-AzureAccount
Select-AzureSubscription -SubscriptionName "Your_Subscription_Name"
$vm = Get-AzureVM -ServiceName "CloudServiceName" -Name "VM_Name"
for ($i=6100; $i -le 6120; $i++)
{
$EndpointName = "FtpEndpoint_"
$EndpointName += $i
Add-AzureEndpoint -Name $EndpointName -Protocol "tcp" -PublicPort $i -LocalPort $i -VM $vm
}
$vm | Update-AzureVM
The actuall service call is performed at bulk when you execute the Update-AzureVM
Starting point for Azure PowerShell reference is here.
I am sure you can achieve the same result also with the XPLAT-CLI.
回答2:
Note that with the last batch of updates (May 2014) you can now map a fixed Public IP to a VM and avoid needing to use cloud service End Points completely. This preview feature requires you to provision a new VM to take advantage of it. The latest Azure PowerShell (0.8.2) also includes the necessary cmdlets to make this work.
New-AzureReservedIP -ReservedIPName EastUSVIP -Label "Reserved VIP in EastUS" -Location "East US"
New-AzureVM -ServiceName "MyApp" -VMs <vm> -Location "East US" -VNetName VNetUSEast -ReservedIPName EastUSVIP
The above sample comes from Scott Guthrie's announcement here: http://weblogs.asp.net/scottgu/archive/2014/05/12/azure-vm-security-extensions-expressroute-ga-reserved-ips-internal-load-balancing-multi-site-to-site-vpns-storage-import-export-ga-new-smb-file-service-api-management-hybrid-connection-service-redis-cache-remote-apps-and-more.aspx
来源:https://stackoverflow.com/questions/23677255/how-to-bulk-add-azure-endpoints