Skip to content

Commit 4be2f57

Browse files
wyunchi-msnitinjainmsdingmeng-xuebbereragauravchandwani1
authored
[CloudService] Init for CloudService (#13571)
* Init for CloudService * Update api-version * Update api-version * Update swagger * Fix the issue of Extension. * Add Switch-AzCloudService * Add some customize * Added test cases * Enabled Reimgae test case * save * Fix issues for Update-AzCloudService and Remove-AzCloudService. * Fixed some issues. * Update CloudService.json * Fix the issue of update-azcloudservice * Fix the serialization issues. * Fix the serialization issues. * #8376112 add role instances * fixes as per swagger changes * Added Remote Desktop Extension cmdlet * Fix some issues * Fix the issue of output index * Upgrade api-version of loadbalancer.json * Still use the local loadbalancer.json * Still use the local loadbalancer.json * Fixed some issues/ * Networking custom cmdlets * Update LoadBalancer.json Updating to change apiversion to 2020-06-01 * Fix the issue of update tag * fixed user name and password in get remote desktop cmdlet * Updating Switch-AzCloudService Updating Switch-AzCloudService to use Invoke-AzRestMethod calls * Added few examples for quick review * Added examples files * Fix issues * Add New-AzCloudServiceVaultSecretGroupObject * Added examples * typo fix * Updated test cases as per Pester framework * Update New-AzCloudService.md * Add example to create cloud service from scratch * Fix the issues * Add record test case * Noflatten of cloud service and no custom * Copied files from custom folder and added no-inline for cloud service objects * Updated Switch-AzCloudService to use the new flattened CS model * Renamed few cmdlet and hide different variants for New and Update cloud service * Fixed test cases as per unflattend version of Az CloudService * White space fixes * Removed GetViaIdentity variant for InstanceView Gets * Updated examples * Updated examples and format-table output for RoleInstanceView and RoleInstance * Display Outfile only for absolute path * Update cmdlets * Added examples for missing cmdlets * Renamed Update-AzCloudServiceUpdateDomain to Set-AzCloudServiceUpdateDomain and updated datafile * Minor fixes in examples and added missing test cases * Update swagger and test cases. * Update Switch-AzCloudService.md * Update Get-AzCloudServiceNetworkInterfaces.md * Update Get-AzCloudServicePublicIPAddress.md * Resolve the credScan issue. * Add help messages. * Fix the variables in string. * Fix the issue of resource path matching. * Remove ApiVersion from parameters. * Fix variable in string. * Fix variable in string. Co-authored-by: wyunchi-ms <[email protected]> Co-authored-by: Nitin Jain <[email protected]> Co-authored-by: dingmeng-xue <[email protected]> Co-authored-by: bberera <[email protected]> Co-authored-by: gauravchandwani1 <[email protected]>
1 parent 976d44f commit 4be2f57

File tree

133 files changed

+19179
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+19179
-0
lines changed

src/CloudService/Az.CloudService.psd1

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@{
2+
GUID = 'a41eb61d-c5a1-4e9b-81a7-b8905fff7f2c'
3+
RootModule = './Az.CloudService.psm1'
4+
ModuleVersion = '0.1.0'
5+
CompatiblePSEditions = 'Core', 'Desktop'
6+
Author = 'Microsoft Corporation'
7+
CompanyName = 'Microsoft Corporation'
8+
Copyright = 'Microsoft Corporation. All rights reserved.'
9+
Description = 'Microsoft Azure PowerShell: CloudService cmdlets'
10+
PowerShellVersion = '5.1'
11+
DotNetFrameworkVersion = '4.7.2'
12+
RequiredAssemblies = './bin/Az.CloudService.private.dll'
13+
FormatsToProcess = './Az.CloudService.format.ps1xml'
14+
FunctionsToExport = 'Get-AzCloudService', 'Get-AzCloudServiceInstanceView', 'Get-AzCloudServiceNetworkInterfaces', 'Get-AzCloudServicePublicIPAddress', 'Get-AzCloudServiceRoleInstance', 'Get-AzCloudServiceRoleInstanceRemoteDesktopFile', 'Get-AzCloudServiceRoleInstanceView', 'Invoke-AzCloudServiceRebuild', 'Invoke-AzCloudServiceReimage', 'Invoke-AzCloudServiceRoleInstanceRebuild', 'Invoke-AzCloudServiceRoleInstanceReimage', 'New-AzCloudService', 'New-AzCloudServiceDiagnosticsExtension', 'New-AzCloudServiceExtensionObject', 'New-AzCloudServiceLoadBalancerConfigurationObject', 'New-AzCloudServiceLoadBalancerFrontendIPConfigurationObject', 'New-AzCloudServiceRemoteDesktopExtensionObject', 'New-AzCloudServiceRoleProfilePropertiesObject', 'New-AzCloudServiceVaultSecretGroupObject', 'Remove-AzCloudService', 'Remove-AzCloudServiceRoleInstance', 'Restart-AzCloudService', 'Restart-AzCloudServiceRoleInstance', 'Set-AzCloudServiceUpdateDomain', 'Start-AzCloudService', 'Stop-AzCloudService', 'Switch-AzCloudService', 'Update-AzCloudService', '*'
15+
AliasesToExport = '*'
16+
PrivateData = @{
17+
PSData = @{
18+
Tags = 'Azure', 'ResourceManager', 'ARM', 'PSModule', 'CloudService'
19+
LicenseUri = 'https://aka.ms/azps-license'
20+
ProjectUri = 'https://github.com/Azure/azure-powershell'
21+
ReleaseNotes = ''
22+
}
23+
}
24+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
2+
# ----------------------------------------------------------------------------------
3+
#
4+
# Copyright Microsoft Corporation
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ----------------------------------------------------------------------------------
15+
16+
<#
17+
.Synopsis
18+
Get the network interfaces of a cloud service.
19+
.Description
20+
Get the network interfaces of a cloud service.
21+
.Link
22+
https://docs.microsoft.com/en-us/powershell/module/az.cloudservice/get-AzCloudServiceNetworkInterfaces
23+
#>
24+
25+
function Get-AzCloudServiceNetworkInterfaces {
26+
param(
27+
[Parameter(ParameterSetName="CloudServiceName", HelpMessage="Subscription.")]
28+
[Parameter(ParameterSetName = "CloudService", HelpMessage="Subscription.")]
29+
[Microsoft.Azure.PowerShell.Cmdlets.CloudService.Category('Path')]
30+
[Microsoft.Azure.PowerShell.Cmdlets.CloudService.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
31+
[System.String]
32+
# Subscription credentials which uniquely identify Microsoft Azure subscription.
33+
# The subscription ID forms part of the URI for every service call.
34+
${SubscriptionId},
35+
36+
[Parameter(Mandatory=$true, ParameterSetName="CloudServiceName", HelpMessage="ResourceGroupName.")]
37+
[string] $ResourceGroupName,
38+
39+
[Parameter(Mandatory=$true, ParameterSetName="CloudServiceName", HelpMessage="CloudServiceName.")]
40+
[string] $CloudServiceName,
41+
42+
[Parameter(ParameterSetName="CloudServiceName", HelpMessage="RoleInstanceName.")]
43+
[Parameter(ParameterSetName = "CloudService", HelpMessage="RoleInstanceName.")]
44+
[string] $RoleInstanceName,
45+
46+
[Parameter(Mandatory=$true, ParameterSetName="CloudService", HelpMessage="CloudService instance.")]
47+
[Microsoft.Azure.PowerShell.Cmdlets.CloudService.Models.Api20201001Preview.CloudService] $CloudService
48+
)
49+
process {
50+
$ApiVersion = "2020-06-01"
51+
if ($PSBoundParameters.ContainsKey("CloudService"))
52+
{
53+
$elements = $CloudService.Id.Split("/")
54+
if (($elements.Count -lt 5) -or ("subscriptions" -ne $elements[1]) -or ("resourceGroups" -ne $elements[3]))
55+
{
56+
throw "CloudService.Id should match the format: /subscriptions/(?<subscriptionId>[^/]+)/resourceGroups/(?<resourceGroupName>[^/]+)"
57+
}
58+
$SubscriptionId = $elements[2]
59+
$ResourceGroupName = $elements[4]
60+
$CloudServiceName = $CloudService.Name
61+
if ($Null -eq $CloudServiceName)
62+
{
63+
throw "CloudService.Name should not be Null"
64+
}
65+
}
66+
67+
# Create the URI as per the input
68+
if ($PSBoundParameters.ContainsKey("RoleInstanceName"))
69+
{
70+
$uriToInvoke = "/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroupName/providers/Microsoft.Compute/cloudServices/$CloudServiceName/roleInstances/$RoleInstanceName/networkInterfaces?api-version=$ApiVersion"
71+
}
72+
else
73+
{
74+
$uriToInvoke = "/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroupName/providers/Microsoft.Compute/cloudServices/$CloudServiceName/networkInterfaces?api-version=$ApiVersion"
75+
}
76+
77+
# Invoke and display the information
78+
$result = Invoke-AzRestMethod -Method GET -Path $uriToInvoke
79+
$result.Content
80+
}
81+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
2+
# ----------------------------------------------------------------------------------
3+
#
4+
# Copyright Microsoft Corporation
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ----------------------------------------------------------------------------------
15+
16+
<#
17+
.Synopsis
18+
Get the public IP address of a cloud service.
19+
.Description
20+
Get the public IP address of a cloud service.
21+
.Link
22+
https://docs.microsoft.com/en-us/powershell/module/az.cloudservice/get-AzCloudServicePublicIPAddress
23+
#>
24+
function Get-AzCloudServicePublicIPAddress {
25+
param(
26+
[Parameter(HelpMessage="Subscription.")]
27+
[Microsoft.Azure.PowerShell.Cmdlets.CloudService.Category('Path')]
28+
[Microsoft.Azure.PowerShell.Cmdlets.CloudService.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
29+
[System.String]
30+
# Subscription credentials which uniquely identify Microsoft Azure subscription.
31+
# The subscription ID forms part of the URI for every service call.
32+
${SubscriptionId},
33+
34+
[Parameter(Mandatory=$true, ParameterSetName="CloudServiceName", HelpMessage="ResourceGroupName.")]
35+
[string] $ResourceGroupName,
36+
37+
[Parameter(Mandatory=$true, ParameterSetName="CloudServiceName", HelpMessage="CloudServiceName.")]
38+
[string] $CloudServiceName,
39+
40+
[Parameter(Mandatory=$true, ParameterSetName="CloudService", HelpMessage="CloudService instance.")]
41+
[Microsoft.Azure.PowerShell.Cmdlets.CloudService.Models.Api20201001Preview.CloudService] $CloudService
42+
)
43+
process {
44+
$ApiVersion = "2020-06-01"
45+
if ($PSBoundParameters.ContainsKey("CloudService"))
46+
{
47+
$elements = $CloudService.Id.Split("/")
48+
if (($elements.Count -lt 5) -or ("subscriptions" -ne $elements[1]) -or ("resourceGroups" -ne $elements[3]))
49+
{
50+
throw "CloudService.Id should match the format: /subscriptions/(?<subscriptionId>[^/]+)/resourceGroups/(?<resourceGroupName>[^/]+)"
51+
}
52+
$SubscriptionId = $elements[2]
53+
$ResourceGroupName = $elements[4]
54+
$CloudServiceName = $CloudService.Name
55+
if ($Null -eq $CloudServiceName)
56+
{
57+
throw "CloudService.Name should not be Null"
58+
}
59+
}
60+
61+
# Create the URI as per the input
62+
$uriToInvoke = "/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroupName/providers/Microsoft.Compute/cloudServices/$CloudServiceName/publicIPAddresses?api-version=$ApiVersion"
63+
64+
# Invoke and display the information
65+
$result = Az.Accounts\Invoke-AzRestMethod -Method GET -Path $uriToInvoke
66+
$result.Content
67+
}
68+
}
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the \"License\");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an \"AS IS\" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
15+
<#
16+
.Synopsis
17+
Create a in-memory object for Diagnostics Extension
18+
.Description
19+
Create a in-memory object for Diagnostics Extension
20+
21+
.Outputs
22+
Microsoft.Azure.PowerShell.Cmdlets.CloudService.Models.Api20201001Preview.Extension
23+
.Link
24+
https://docs.microsoft.com/en-us/powershell/module/az.CloudService/new-AzCloudServiceExtensionObject
25+
#>
26+
27+
function New-AzCloudServiceDiagnosticsExtension {
28+
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.CloudService.Models.Api20201001Preview.Extension')]
29+
param(
30+
[Parameter(HelpMessage="Name of Diagnostics Extension.", Mandatory)]
31+
[string] $Name,
32+
33+
[Parameter(HelpMessage="Subscription.")]
34+
[Microsoft.Azure.PowerShell.Cmdlets.CloudService.Category('Path')]
35+
[Microsoft.Azure.PowerShell.Cmdlets.CloudService.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
36+
[System.String]
37+
# Subscription credentials which uniquely identify Microsoft Azure subscription.
38+
# The subscription ID forms part of the URI for every service call.
39+
${Subscription},
40+
41+
[Parameter(HelpMessage="Resource Group name of Cloud Service.", Mandatory)]
42+
[string] $ResourceGroupName,
43+
44+
[Parameter(HelpMessage="Name of Cloud Service.", Mandatory)]
45+
[string] $CloudServiceName,
46+
47+
[Parameter(HelpMessage="Specifies the configuration for Azure Diagnostics. You can download the schema by using the following command: (Get-AzureServiceAvailableExtension -ExtensionName 'PaaSDiagnostics' -ProviderNamespace 'Microsoft.Azure.Diagnostics').PublicConfigurationSchema | Out-File -Encoding utf8 -FilePath 'WadConfig.xsd'", Mandatory)]
48+
[string] $DiagnosticsConfigurationPath,
49+
50+
[Parameter(HelpMessage="Name of the Storage Account.", Mandatory)]
51+
[string] $StorageAccountName,
52+
53+
[Parameter(HelpMessage="Storage Account Key.", Mandatory)]
54+
[string] $StorageAccountKey,
55+
56+
[Parameter(HelpMessage="Specifies the version of the extension.")]
57+
[string] $TypeHandlerVersion,
58+
59+
[Parameter(HelpMessage="Roles applied to.")]
60+
[string[]] $RolesAppliedTo,
61+
62+
[Parameter(HelpMessage="Auto upgrade minor version.")]
63+
[Boolean] $AutoUpgradeMinorVersion
64+
)
65+
66+
process {
67+
$publisher = "Microsoft.Azure.Diagnostics"
68+
$extensionType = "PaaSDiagnostics"
69+
70+
if (!(Test-Path $DiagnosticsConfigurationPath -PathType Leaf))
71+
{
72+
throw ("DiagnosticsConfigurationPath does not exits: " + $DiagnosticsConfigurationPath)
73+
}
74+
75+
[xml]$diagnosticsConfigurationXml = Get-Content $DiagnosticsConfigurationPath
76+
77+
$storageAccount = $diagnosticsConfigurationXml.PublicConfig.ChildNodes | Where-Object { $_.Name -eq 'StorageAccount' }
78+
if ($storageAccount)
79+
{
80+
Write-Host "Using StorageAccount information defined in diagnostics configuration file."
81+
}
82+
else
83+
{
84+
$storageAccount = $diagnosticsConfigurationXml.CreateElement('StorageAccount', $diagnosticsConfigurationXml.PublicConfig.NamespaceURI)
85+
$storageAccount.InnerText = $StorageAccountName
86+
$storageAccount = $diagnosticsConfigurationXml.PublicConfig.AppendChild($storageAccount)
87+
}
88+
89+
$metrics = $diagnosticsConfigurationXml.PublicConfig.WadCfg.DiagnosticMonitorConfiguration.ChildNodes | Where-Object { $_.Name -eq 'Metrics' }
90+
if ($metrics)
91+
{
92+
Write-Host "Using Metrics information defined in diagnostics configuration file."
93+
}
94+
else
95+
{
96+
$metrics = $diagnosticsConfigurationXml.CreateElement('Metrics', $diagnosticsConfigurationXml.PublicConfig.NamespaceURI)
97+
$resourceId = "/subscriptions/$Subscription/resourceGroups/$ResourceGroupName/providers/Microsoft.Compute/cloudservices/$CloudServiceName"
98+
$metrics.SetAttribute('resourceId', $resourceId)
99+
$metrics = $diagnosticsConfigurationXml.PublicConfig.WadCfg.DiagnosticMonitorConfiguration.AppendChild($metrics)
100+
}
101+
102+
$setting = $diagnosticsConfigurationXml.PublicConfig.OuterXml
103+
104+
$privateConfig = $diagnosticsConfigurationXml.ChildNodes | Where-Object { $_.Name -eq 'PrivateConfig' }
105+
if ($privateConfig)
106+
{
107+
$protectedSetting = $privateConfig.OuterXml
108+
Write-Host "Using PrivateConfig information defined in diagnostics configuration file."
109+
}
110+
else
111+
{
112+
$storageEndpoint = "https://core.windows.net"
113+
$protectedSetting = '<?xml version="1.0" encoding="UTF-8"?><PrivateConfig xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration"><StorageAccount endpoint="' + $storageEndpoint + '" key="' + $StorageAccountKey + '" name="' + $storageAccountName + '"/></PrivateConfig>'
114+
}
115+
116+
return New-AzCloudServiceExtensionObject -Name $Name -Publisher $publisher -Type $extensionType -TypeHandlerVersion $TypeHandlerVersion -Setting $setting -ProtectedSetting $protectedSetting -RolesAppliedTo $RolesAppliedTo -AutoUpgradeMinorVersion $AutoUpgradeMinorVersion
117+
}
118+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
2+
# ----------------------------------------------------------------------------------
3+
#
4+
# Copyright Microsoft Corporation
5+
# Licensed under the Apache License, Version 2.0 (the \"License\");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an \"AS IS\" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ----------------------------------------------------------------------------------
15+
16+
<#
17+
.Synopsis
18+
Create a in-memory object for Extension
19+
.Description
20+
Create a in-memory object for Extension
21+
22+
.Outputs
23+
Microsoft.Azure.PowerShell.Cmdlets.CloudService.Models.Api20201001Preview.Extension
24+
.Link
25+
https://docs.microsoft.com/en-us/powershell/module/az.CloudService/new-AzCloudServiceExtensionObject
26+
#>
27+
function New-AzCloudServiceExtensionObject {
28+
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.CloudService.Models.Api20201001Preview.Extension')]
29+
[CmdletBinding(PositionalBinding=$false)]
30+
Param(
31+
32+
[Parameter(HelpMessage="Explicitly specify whether CRP can automatically upgrade typeHandlerVersion to higher minor versions when they become available.")]
33+
[bool]
34+
$AutoUpgradeMinorVersion,
35+
[Parameter(HelpMessage="Name.")]
36+
[string]
37+
$Name,
38+
[Parameter(HelpMessage="Protected settings for the extension which are encrypted before sent to the VM.")]
39+
[string]
40+
$ProtectedSetting,
41+
[Parameter(HelpMessage="Publisher.")]
42+
[string]
43+
$Publisher,
44+
[Parameter(HelpMessage="RolesAppliedTo.")]
45+
[string[]]
46+
$RolesAppliedTo,
47+
[Parameter(HelpMessage="Public settings for the extension.")]
48+
[string]
49+
$Setting,
50+
[Parameter(HelpMessage="Type.")]
51+
[string]
52+
$Type,
53+
[Parameter(HelpMessage="TypeHandlerVersion.")]
54+
[string]
55+
$TypeHandlerVersion
56+
)
57+
58+
process {
59+
$Object = [Microsoft.Azure.PowerShell.Cmdlets.CloudService.Models.Api20201001Preview.Extension]::New()
60+
61+
$Object.AutoUpgradeMinorVersion = $AutoUpgradeMinorVersion
62+
$Object.Name = $Name
63+
$Object.ProtectedSetting = $ProtectedSetting
64+
$Object.Publisher = $Publisher
65+
$Object.RolesAppliedTo = $RolesAppliedTo
66+
$Object.Setting = $Setting
67+
$Object.Type = $Type
68+
$Object.TypeHandlerVersion = $TypeHandlerVersion
69+
return $Object
70+
}
71+
}
72+

0 commit comments

Comments
 (0)