Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to setup Scale Set on existing Vnet Using Custom Image #44

Open
avshetty opened this issue Jan 18, 2018 · 0 comments
Open

Trying to setup Scale Set on existing Vnet Using Custom Image #44

avshetty opened this issue Jan 18, 2018 · 0 comments

Comments

@avshetty
Copy link

Im trying to create a ScaleSet in an EXISTING Virtual Network using a Custom Image.

I have created a custom image using Packer and passed it to the script shown below.

Everything works perfectly, but the last few lines do not execute as expected.

Can anyone have a look at the attached script and let me know if you find something wrong.

Any help will be appreciated.

Thank you

Error Received

New-AzureRmVmss : Cannot parse the request. ErrorCode: InvalidRequestFormat ErrorMessage: Cannot parse the request. StatusCode: 400 ReasonPhrase: Bad Request OperationID : 9362b990-2503-400f-a91f-7848de736bce At C:\Users\aditya\desktop\ScaleSet.ps1:92 char:1 + New-AzureRmVmss -ResourceGroupName $rgname -Name $vmssName -VirtualMa ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [New-AzureRmVmss], ComputeCloudException + FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.Automation.NewAzureRmVmss

SCRIPT

$VNet = Get-AzureRmVirtualNetwork -Name * -ResourceGroupName *
$SubNetId = $VNet.Subnets[10].Id;
$rgname = ''
$loc = 'South Central US'
$imageurl = '
'

$pubip = New-AzureRmPublicIpAddress -Force -Name * -ResourceGroupName
$rgname -Location $loc -AllocationMethod Dynamic -DomainNameLabel *;
$pubip = Get-AzureRmPublicIpAddress -Name * -ResourceGroupName $rgname;
Write-Output "Created Public IP Address ..... "
$frontendName = 'fe' + $rgname
$backendAddressPoolName = 'bepool' + $rgname
$probeName = 'vmssprobe' + $rgname
$inboundNatPoolName = 'innatpool' + $rgname
$lbruleName = 'HTTP'
$lbruleName2 = 'HTTP2'
$lbName = 'myElb'

Bind Public IP to Load Balancer

$frontend = New-AzureRmLoadBalancerFrontendIpConfig -Name $frontendName -
PublicIpAddress $pubip

$backendAddressPool = New-AzureRmLoadBalancerBackendAddressPoolConfig -Name
$backendAddressPoolName

$probe = New-AzureRmLoadBalancerProbeConfig -Name $probeName -RequestPath
'/' -Protocol http -Port 80 -IntervalInSeconds 15 -ProbeCount 2

$frontendpoolrangestart = 3360
$frontendpoolrangeend = 3370
$backendvmport = 3389
$inboundNatPool = New-AzureRmLoadBalancerInboundNatPoolConfig -Name
$inboundNatPoolName -FrontendIPConfigurationId `
$frontend.Id -Protocol Tcp -FrontendPortRangeStart $frontendpoolrangestart -
FrontendPortRangeEnd $frontendpoolrangeend -BackendPort $backendvmport;

$protocol = 'Tcp'
$feLBPort = 443
$beLBPort = 443
$feLBPort2 = 2021
$beLBPort2 = 2021

$lbrule = New-AzureRmLoadBalancerRuleConfig -Name $lbruleName -FrontendIPConfiguration $frontend -BackendAddressPool $backendAddressPool
-Probe $probe -Protocol $protocol -FrontendPort $feLBPort -BackendPort
$beLBPort

$lbrule2 = New-AzureRmLoadBalancerRuleConfig -Name $lbruleName2 -FrontendIPConfiguration $frontend -BackendAddressPool $backendAddressPool
-Probe $probe -Protocol $protocol -FrontendPort $feLBPort2 -BackendPort
$beLBPort2

$actualLb = New-AzureRmLoadBalancer -Name $lbName -ResourceGroupName $rgname
-Location $loc -FrontendIpConfiguration $frontend -BackendAddressPool $backendAddressPool
-Probe $probe -LoadBalancingRule $lbrule,$lbrule2 -InboundNatPool
$inboundNatPool -Verbose;

$expectedLb = Get-AzureRmLoadBalancer -Name $lbName -ResourceGroupName
$rgname
Write-Output "Created Load Balancer ..... "

specify VMSS specific details

$adminUsername = '';
$adminPassword = "
";

$PublisherName = 'MicrosoftWindowsServer'
$Offer = 'WindowsServer'
$Sku = '2012-R2-Datacenter'
$Version = 'latest'
$vmNamePrefix = 'winvmss'

###add an extension
$extname = 'BGInfo';
$publisher = 'Microsoft.Compute';
$exttype = 'BGInfo';
$extver = '2.1';

$ipCfg = New-AzureRmVmssIPConfig -Name 'nic' -LoadBalancerInboundNatPoolsId $actualLb.InboundNatPools[0].Id
-LoadBalancerBackendAddressPoolsId $actualLb.BackendAddressPools[0].Id `
-SubnetId $subnetId;

$vmssName = 'mysscalesetop'

Specify number of nodes

$numberofnodes = 2

$vmss = New-AzureRmVmssConfig -Location $loc -SkuCapacity $numberofnodes -
SkuName 'Standard_D2' -UpgradePolicyMode 'automatic' | Add-AzureRmVmssNetworkInterfaceConfiguration -Name $subnetName -Primary $true -IPConfiguration $ipCfg
| Set-AzureRmVmssOSProfile -ComputerNamePrefix $vmNamePrefix -AdminUsername
$adminUsername -AdminPassword $adminPassword `
| Set-AzureRmVmssStorageProfile -Image $imageurl -OsDiskOsType Windows -Name
"vmssosdk"

New-AzureRmVmss -ResourceGroupName $rgname -Name $vmssName -
VirtualMachineScaleSet $vmss;

Write-Output "Created Scale Set using the custom image "

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant