Skip to content

Commit ad5abea

Browse files
authored
add cmdlet open-azsurveylink (#15205)
* add cmdlet open-azsurveylink * move new cmdlet under feedback folder * remove white space * add help markdown for new cmdlet * update common version * suppress signature issue * update parent class * update namespace for share assembly * upgrade common version * add example * fix help markdown * add required assembly
1 parent 1bbde85 commit ad5abea

File tree

7 files changed

+151
-18
lines changed

7 files changed

+151
-18
lines changed

src/Accounts/Accounts/Az.Accounts.psd1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ RequiredAssemblies = 'Microsoft.Azure.PowerShell.Authentication.Abstractions.dll
7878
'Microsoft.WindowsAzure.Storage.dll',
7979
'Microsoft.WindowsAzure.Storage.DataMovement.dll',
8080
'Microsoft.Azure.PowerShell.Clients.Aks.dll',
81-
'Microsoft.Azure.PowerShell.Strategies.dll'
81+
'Microsoft.Azure.PowerShell.Strategies.dll',
82+
'Microsoft.Azure.PowerShell.Common.Share.dll'
8283

8384
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
8485
# ScriptsToProcess = @()
@@ -106,7 +107,8 @@ CmdletsToExport = 'Disable-AzDataCollection', 'Disable-AzContextAutosave',
106107
'Disconnect-AzAccount', 'Get-AzContextAutosaveSetting',
107108
'Set-AzDefault', 'Get-AzDefault', 'Clear-AzDefault',
108109
'Register-AzModule', 'Enable-AzureRmAlias', 'Disable-AzureRmAlias',
109-
'Uninstall-AzureRm', 'Invoke-AzRestMethod', 'Get-AzAccessToken'
110+
'Uninstall-AzureRm', 'Invoke-AzRestMethod', 'Get-AzAccessToken',
111+
'Open-AzSurveyLink'
110112

111113
# Variables to export from this module
112114
# VariablesToExport = @()

src/Accounts/Accounts/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
-->
2020

2121
## Upcoming Release
22+
* Added cmdlet `Open-AzSurveyLink`
2223
* Supported certificate file as input parameter of Connect-AzAccount
2324

2425
## Version 2.3.0
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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+
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
16+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
17+
using System;
18+
using System.Diagnostics;
19+
using System.Management.Automation;
20+
using System.Runtime.InteropServices;
21+
22+
namespace Microsoft.Azure.Commands.Profile.Survey
23+
{
24+
[Cmdlet(VerbsCommon.Open, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "SurveyLink"), OutputType(typeof(void))]
25+
public class OpenAzSurveyLinkCmdlet : AzurePSCmdlet
26+
{
27+
private const string _surveyLinkFormat = "https://aka.ms/azpssurvey?Q_CHL=INTERCEPT";
28+
29+
protected override IAzureContext DefaultContext => null;
30+
31+
protected override string DataCollectionWarning => null;
32+
33+
public override void ExecuteCmdlet()
34+
{
35+
WriteInformation(new HostInformationMessage() { Message = $"Opening the default browser to {_surveyLinkFormat}" }, new string[] { "PSHOST" });
36+
OpenBrowser(_surveyLinkFormat);
37+
}
38+
39+
private void OpenBrowser(string url)
40+
{
41+
try
42+
{
43+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
44+
{
45+
url = url.Replace("&", "^&");
46+
Process.Start(new ProcessStartInfo("cmd", $"/c start {url}") { CreateNoWindow = true });
47+
}
48+
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
49+
{
50+
Process.Start("xdg-open", url);
51+
}
52+
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
53+
{
54+
Process.Start("open", url);
55+
}
56+
else
57+
{
58+
throw new PlatformNotSupportedException(RuntimeInformation.OSDescription);
59+
}
60+
}
61+
catch
62+
{
63+
}
64+
}
65+
}
66+
}

src/Accounts/Accounts/help/Az.Accounts.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ Loads Azure authentication information from a file.
8181
### [Invoke-AzRestMethod](Invoke-AzRestMethod.md)
8282
Construct and perform HTTP request to Azure resource management endpoint only
8383

84+
### [Open-AzSurveyLink](Open-AzSurveyLink.md)
85+
Open survey link in default browser.
86+
8487
### [Register-AzModule](Register-AzModule.md)
8588
FOR INTERNAL USE ONLY - Provide Runtime Support for AutoRest Generated cmdlets
8689

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
external help file: Microsoft.Azure.PowerShell.Cmdlets.Accounts.dll-Help.xml
3+
Module Name: Az.Accounts
4+
online version: https://docs.microsoft.com/powershell/module/az.accounts/open-azsurveylink
5+
schema: 2.0.0
6+
---
7+
8+
# Open-AzSurveyLink
9+
10+
## SYNOPSIS
11+
Open survey link in default browser.
12+
13+
## SYNTAX
14+
15+
```
16+
Open-AzSurveyLink [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
17+
```
18+
19+
## DESCRIPTION
20+
Open survey link in default browser.
21+
22+
## EXAMPLES
23+
24+
### Example 1
25+
```
26+
Open-AzSurveyLink
27+
Opening the default browser to https://aka.ms/azpssurvey?Q_CHL=INTERCEPT
28+
```
29+
30+
## PARAMETERS
31+
32+
### -DefaultProfile
33+
The credentials, account, tenant, and subscription used for communication with Azure.
34+
35+
```yaml
36+
Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
37+
Parameter Sets: (All)
38+
Aliases: AzContext, AzureRmContext, AzureCredential
39+
40+
Required: False
41+
Position: Named
42+
Default value: None
43+
Accept pipeline input: False
44+
Accept wildcard characters: False
45+
```
46+
47+
### CommonParameters
48+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
49+
50+
## INPUTS
51+
52+
### None
53+
54+
## OUTPUTS
55+
56+
## NOTES
57+
58+
## RELATED LINKS

tools/Common.Netcore.Dependencies.targets

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,22 @@
33
<ItemGroup>
44
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.23"/>
55
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure" Version="3.3.19"/>
6-
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Aks" Version="1.3.34-preview"/>
7-
<PackageReference Include="Microsoft.Azure.PowerShell.Authentication.Abstractions" Version="1.3.34-preview"/>
8-
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Authorization" Version="1.3.34-preview"/>
9-
<PackageReference Include="Microsoft.Azure.PowerShell.Common" Version="1.3.34-preview"/>
10-
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Compute" Version="1.3.34-preview"/>
11-
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Graph.Rbac" Version="1.3.34-preview"/>
12-
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.KeyVault" Version="1.3.34-preview"/>
13-
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Monitor" Version="1.3.34-preview"/>
14-
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Network" Version="1.3.34-preview"/>
15-
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.PolicyInsights" Version="1.3.34-preview"/>
16-
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.ResourceManager" Version="1.3.34-preview"/>
17-
<PackageReference Include="Microsoft.Azure.PowerShell.Storage" Version="1.3.34-preview"/>
18-
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Storage.Management" Version="1.3.34-preview"/>
19-
<PackageReference Include="Microsoft.Azure.PowerShell.Strategies" Version="1.3.34-preview"/>
20-
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Websites" Version="1.3.34-preview"/>
6+
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Aks" Version="1.3.36-preview"/>
7+
<PackageReference Include="Microsoft.Azure.PowerShell.Authentication.Abstractions" Version="1.3.36-preview"/>
8+
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Authorization" Version="1.3.36-preview"/>
9+
<PackageReference Include="Microsoft.Azure.PowerShell.Common" Version="1.3.36-preview"/>
10+
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Compute" Version="1.3.36-preview"/>
11+
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Graph.Rbac" Version="1.3.36-preview"/>
12+
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.KeyVault" Version="1.3.36-preview"/>
13+
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Monitor" Version="1.3.36-preview"/>
14+
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Network" Version="1.3.36-preview"/>
15+
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.PolicyInsights" Version="1.3.36-preview"/>
16+
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.ResourceManager" Version="1.3.36-preview"/>
17+
<PackageReference Include="Microsoft.Azure.PowerShell.Storage" Version="1.3.36-preview"/>
18+
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Storage.Management" Version="1.3.36-preview"/>
19+
<PackageReference Include="Microsoft.Azure.PowerShell.Strategies" Version="1.3.36-preview"/>
20+
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Websites" Version="1.3.36-preview"/>
21+
<PackageReference Include="Microsoft.Azure.PowerShell.Common.Share" Version="1.3.36-preview"/>
2122
</ItemGroup>
2223
<ItemGroup>
2324
<PackageReference Include="Azure.Core" Version="1.14.0"/>
@@ -35,7 +36,7 @@
3536
<PackageReference Include="PowerShellStandard.Library" Version="5.1.0" PrivateAssets="All" />
3637
</ItemGroup>
3738
<PropertyGroup>
38-
<StorageToolsPath>$(NugetPackageRoot)\microsoft.azure.powershell.storage\1.3.34-preview\tools\</StorageToolsPath>
39+
<StorageToolsPath>$(NugetPackageRoot)\microsoft.azure.powershell.storage\1.3.36-preview\tools\</StorageToolsPath>
3940
</PropertyGroup>
4041
<ItemGroup Condition="'$(OmitJsonPackage)' != 'true'">
4142
<PackageReference Include="Newtonsoft.Json" Version="10.0.3"/>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
"AssemblyFileName","ClassName","Target","Severity","ProblemId","Description","Remediation"
2+
"Az.Accounts","Microsoft.Azure.Commands.Profile.Survey.OpenAzSurveyLinkCmdlet","Open-AzSurveyLink","1","8100","Open-AzSurveyLink Does not support ShouldProcess but the cmdlet verb Open indicates that it should.","Determine if the cmdlet should implement ShouldProcess and if so determine if it should implement Force / ShouldContinue"

0 commit comments

Comments
 (0)