다음을 통해 공유


AzurePack: Creating and configuring a plan using PowerShell

 

Import-Module 'MgmtSvcAdmin'
 
# environment settings
$AuthSiteURL= 'https://waptest:30072'
$AdminSiteURL= 'https://waptest:30004'
$ClientRealmUrl = 'https://azureservices/AdminSite'
 
# credentials and token
$password = ConvertTo-SecureString "password" -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential ("domain\username",$password)
$token = Get-MgmtSvcToken -Type Windows -AuthenticationSite $AuthSiteURL -ClientRealm $ClientRealmUrl -User $credential -DisableCertificateValidation
 
# plan / service settings
$PlanDisplayName = 'PlanName'
$planServiceName = 'systemcenter'
$serviceDisplayName = 'Virtual Machine Clouds'
$serviceInstanceDisplayName = 'Virtual Machine Clouds'
 
# quota settings (for System Center, these values are complex and depend upon the environment; one example shown for each)
$quotaSettingKey1 = "Actions"
$quotaSettingValue1 = '<Actions><Stamp Id="bbb46507-5cdd-4d23-830b-080ca2d5ff29"><Action>Checkpoint</Action><Action>CheckpointRestoreOnly</Action><Action>Save</Action><Action>Store</Action>

<Action>RemoteConnect</Action><Action>Author</Action><Action>Create</Action><Action>CreateFromVHDOrTemplate</Action>

<Action>AllowLocalAdmin</Action><Action>Start</Action><Action>Stop</Action><Action>PauseAndResume</Action><Action>Shutdown</Action>

<Action>Remove</Action><Action MaximumNetwork="" MaximumMemberNetwork="" MaximumBandwidthIn="" MaximumBandwidthOut="" MaximumVPNConnection="99" MaximumMemberVPNConnection="99">AuthorVMNetwork</Action></Stamp></Actions>'
 
$quotaSettingKey2 = "Clouds"
$quotaSettingValue2 = '<Clouds><Cloud Id="2b5cc12d-892b-45af-adcf-8f0f6df6eb35" StampId="bbb46507-5cdd-4d23-830b-080ca2d5ff29"><Quota><RoleVMCount></RoleVMCount><MemberVMCount></MemberVMCount><RoleCPUCount></RoleCPUCount>

<MemberCPUCount></MemberCPUCount><RoleMemoryMB></RoleMemoryMB><MemberMemoryMB></MemberMemoryMB>

<RoleStorageGB></RoleStorageGB><MemberStorageGB></MemberStorageGB></Quota></Cloud></Clouds>'
 
$quotaSettingKey3 = "VmResources"
$quotaSettingValue3 = '<Resources><HardwareProfile Id = "326fbb68-7ee7-4459-bc84-047bff491512" StampId="bbb46507-5cdd-4d23-830b-080ca2d5ff29"/><VmTemplate Id = "b88c24e0-06a1-4ed0-bfbc-22e2949002ac" StampId="bbb46507-5cdd-4d23-830b-080ca2d5ff29"/><GalleryItem Name = "LarysaResDef" Version = "3.0.0.0" Publisher = "UnspecifiedPublisher" StampId="bbb46507-5cdd-4d23-830b-080ca2d5ff29"/></Resources>'
 
$quotaSettingKey4 = "Networks"
$quotaSettingValue4 = '<Networks><Network Id = "354a27eb-2705-4073-9dbb-52cec271f839" StampId="bbb46507-5cdd-4d23-830b-080ca2d5ff29"/></Networks>'
 
$quotaSettingKey4 = "CustomSettings"
$quotaSettingValue4 = '<CustomSettings></CustomSettings>'
 
# Add a new public Management Service plan
$plan = Add-MgmtSvcPlan $AdminSiteURL $token -DisableCertificateValidation -DisplayName $PlanDisplayName -State Public
 
# Retrieve the System Center resource provider config data (the System Center resource provider should already exist in the Management Service node)
$systemCenterRP = Get-MgmtSvcResourceProvider -AdminUri $AdminSiteURL -token $token -disablecertificatevalidation -name $planServiceName
 
# Add the System Center service to the plan created
Add-MgmtSvcPlanService $AdminSiteURL $token -DisableCertificateValidation -PlanId $plan.Id -ServiceName $planServiceName -InstanceId $systemCenterRP.InstanceId
 
# Add Quotas to the plan created
$QuotaList = New-MgmtSvcQuotaList
 
$quota = Add-MgmtSvcListQuota -QuotaList $QuotaList -ServiceName $planServiceName -ServiceInstanceId $systemCenterRP.InstanceId
$quota.ServiceDisplayName = $serviceDisplayName
$quota.ServiceInstanceDisplayName = $serviceInstanceDisplayName
 
# add each of the key:value quota settings to the quota (each saved into settings variable for debug inspection or logging)
$setting1 = Add-MgmtSvcQuotaSetting -Quota $quota -Key $quotaSettingKey1 -Value $quotaSettingValue1
$setting2 = Add-MgmtSvcQuotaSetting -Quota $quota -Key $quotaSettingKey2 -Value $quotaSettingValue2
$setting3 = Add-MgmtSvcQuotaSetting -Quota $quota -Key $quotaSettingKey3 -Value $quotaSettingValue3
$setting4 = Add-MgmtSvcQuotaSetting -Quota $quota -Key $quotaSettingKey4 -Value $quotaSettingValue4
 
Update-MgmtSvcPlanQuota $AdminSiteURL $token -DisableCertificateValidation -PlanId $plan.Id -QuotaList $QuotaList -Verbose