Azure üzerinde hizmet veren Sanal Makinelerimize ihtiyaçlarımızdan dolayı Static IP verilebiliyoruz. Bu işlemi gerçekleştirmek için bir çok yöntemler bulunmaktadır. Azure Preview Portal üzerinden isterseniz de Azure Powershell ile hesabınızı tanıtıp, istemiş olduğunuz Sanal Makinemize Static IP atamaları gerçekleştirebilirsiniz. Fakat bu işlemleri gerçekleştirirken hangi Sanal Makine Static yada Dynamic şimdilik bilemiyoruz. Azure Portal ve Preview Portal tarafında bu tarz bir rapor olmadığı için geliştirmiş olduğum Powershell Fonksiyonu sizlere yardımcı olacaktır.
Function : Get-AzureVMStaticIPList
function Get-AzureVMStaticIPList{
BEGIN{
try
{
Write-Host "Importing Azure PowerShell Module." -ForegroundColor Magenta
Import-Module -Name 'Azure' -ErrorAction Stop
Write-Host "Getting the list of all Azure VM" -ForegroundColor Magenta
$VmList = Get-AzureVM -ErrorAction Stop
#Select Default AzureSubscription
$subs = Get-AzureSubscription | Where-Object IsDefault -eq $true
Select-AzureSubscription -SubscriptionId $subs.SubscriptionId
}
catch
{
Write-Host "Exception Occured : $_.Exception"
}
}
PROCESS{
$i = 1
$array= @()
Write-Host "Exporting to Powershell Console" -ForegroundColor Magenta
foreach ($vm in $VmList){
$ResultIP = $vm | Get-AzureStaticVNetIP
$counter = $i++
$obj=New-Object PSObject
$obj |Add-Member -MemberType NoteProperty -Name "SerialNumber" $counter
$obj |Add-Member -MemberType NoteProperty -Name "Name" $vm.Name
$obj |Add-Member -MemberType NoteProperty -Name "DNS Name" $vm.DNSName
$obj |Add-Member -MemberType NoteProperty -Name "Instance Size" $vm.InstanceSize
$obj |Add-Member -MemberType NoteProperty -Name "Internal IP" $vm.IpAddress
if($ResultIP)
{
$obj |Add-Member -MemberType NoteProperty -Name "Static" "Yes"
}
else
{
$obj |Add-Member -MemberType NoteProperty -Name "Static" "No"
}
$obj |Add-Member -MemberType NoteProperty -Name "PublicIP" $vm.PublicIPAddress
$array += $obj}
$array | Select-Object SerialNumber,Name,"DNS Name","Instance Size", `
"Internal IP",Static | Ft -AutoSize}
END{
Write-Host "Script run finishes at : $(get-date)"
}
}