-
Notifications
You must be signed in to change notification settings - Fork 14
/
New-AzureServiceDefinition.ps1
68 lines (63 loc) · 2.27 KB
/
New-AzureServiceDefinition.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
function New-AzureServiceDefinition
{
<#
.Synopsis
Creates a new Azure Service Definition XML
.Description
Creates a new Azure Service Definition XML.
Additional commands are used to modify the XML's settings
.Example
New-AzureServiceDefinition -ServiceName TestService |
Add-AzureWebSite -HostHeader www.testsite.com -PhysicalDirectory 'C:\inetpub\wwwroot\testsite'
.Link
Add-AzureRole
.Link
Add-AzureStartupTask
.Link
Add-AzureWebSite
.Link
Add-AzureLocalResource
#>
[OutputType([xml],[string])]
param(
# Required. The name of the service. The name must be unique within the service account.
[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)]
[Alias('Name')]
[String]
$ServiceName,
<#
Optional. Specifies the number of upgrade domains across which roles in this service are allocated.
Role instances are allocated to an upgrade domain when the service is deployed. For more information,
see "How to Perform In-Place Upgrades" on MSDN.
You can specify up to 5 upgrade domains. If not specified, the default number of upgrade domains is 5.
#>
[int]
$UpgradeDomainCount,
# If set, will output the XML as text. If this is not set, an XmlElement is returned.
[switch]
$AsString
)
process {
#region Declare the root XML
if ($psBoundParameters.ContainsKey('UpgradeDomainCount')) {
$def = @"
<ServiceDefinition name="$ServiceName" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" upgradeDomainCount="$UpgradeDomainCount" />
"@
} else {
$def = @"
<ServiceDefinition name="$ServiceName" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" />
"@
}
#endregion Declare the root XML
#region Output the configuration
$xml = [xml]$def
if ($AsString) {
$strWrite = New-Object IO.StringWriter
$xml.Save($strWrite)
return "$strWrite"
} else {
$Xml
}
#endregion Output the configuration
}
}