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

add cmdlet open-azsurveylink #15205

Merged
merged 16 commits into from
Jun 10, 2021
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Accounts/Accounts/Az.Accounts.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ RequiredAssemblies = 'Microsoft.Azure.PowerShell.Authentication.Abstractions.dll
'Microsoft.WindowsAzure.Storage.dll',
'Microsoft.WindowsAzure.Storage.DataMovement.dll',
'Microsoft.Azure.PowerShell.Clients.Aks.dll',
'Microsoft.Azure.PowerShell.Strategies.dll'
'Microsoft.Azure.PowerShell.Strategies.dll',
'Microsoft.Azure.PowerShell.Common.Share.dll'

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

# Variables to export from this module
# VariablesToExport = @()
Expand Down
1 change: 1 addition & 0 deletions src/Accounts/Accounts/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
-->

## Upcoming Release
* Added cmdlet `Open-AzSurveyLink`
* Supported certificate file as input parameter of Connect-AzAccount

## Version 2.3.0
Expand Down
66 changes: 66 additions & 0 deletions src/Accounts/Accounts/Feedback/OpenAzSurveyLinkCmdlet.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using System;
using System.Diagnostics;
using System.Management.Automation;
using System.Runtime.InteropServices;

namespace Microsoft.Azure.Commands.Profile.Survey
{
[Cmdlet(VerbsCommon.Open, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "SurveyLink"), OutputType(typeof(void))]
public class OpenAzSurveyLinkCmdlet : AzurePSCmdlet
{
private const string _surveyLinkFormat = "https://aka.ms/azpssurvey?Q_CHL=INTERCEPT";

protected override IAzureContext DefaultContext => null;

protected override string DataCollectionWarning => null;

public override void ExecuteCmdlet()
{
WriteInformation(new HostInformationMessage() { Message = $"Opening the default browser to {_surveyLinkFormat}" }, new string[] { "PSHOST" });
OpenBrowser(_surveyLinkFormat);
}

private void OpenBrowser(string url)
{
try
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
url = url.Replace("&", "^&");
Process.Start(new ProcessStartInfo("cmd", $"/c start {url}") { CreateNoWindow = true });
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
Process.Start("xdg-open", url);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
Process.Start("open", url);
}
else
{
throw new PlatformNotSupportedException(RuntimeInformation.OSDescription);
}
}
catch
{
}
}
}
}
3 changes: 3 additions & 0 deletions src/Accounts/Accounts/help/Az.Accounts.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ Loads Azure authentication information from a file.
### [Invoke-AzRestMethod](Invoke-AzRestMethod.md)
Construct and perform HTTP request to Azure resource management endpoint only

### [Open-AzSurveyLink](Open-AzSurveyLink.md)
Open survey link in default browser.

### [Register-AzModule](Register-AzModule.md)
FOR INTERNAL USE ONLY - Provide Runtime Support for AutoRest Generated cmdlets

Expand Down
58 changes: 58 additions & 0 deletions src/Accounts/Accounts/help/Open-AzSurveyLink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
external help file: Microsoft.Azure.PowerShell.Cmdlets.Accounts.dll-Help.xml
Module Name: Az.Accounts
online version: https://docs.microsoft.com/powershell/module/az.accounts/open-azsurveylink
schema: 2.0.0
---

# Open-AzSurveyLink

## SYNOPSIS
Open survey link in default browser.

## SYNTAX

```
Open-AzSurveyLink [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
```

## DESCRIPTION
Open survey link in default browser.

## EXAMPLES
VeryEarly marked this conversation as resolved.
Show resolved Hide resolved

### Example 1
```
Open-AzSurveyLink
Opening the default browser to https://aka.ms/azpssurvey?Q_CHL=INTERCEPT
```

## PARAMETERS

### -DefaultProfile
The credentials, account, tenant, and subscription used for communication with Azure.

```yaml
Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
Parameter Sets: (All)
Aliases: AzContext, AzureRmContext, AzureCredential

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### CommonParameters
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).

## INPUTS

### None

## OUTPUTS

## NOTES

## RELATED LINKS
33 changes: 17 additions & 16 deletions tools/Common.Netcore.Dependencies.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@
<ItemGroup>
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.23"/>
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure" Version="3.3.19"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Aks" Version="1.3.34-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Authentication.Abstractions" Version="1.3.34-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Authorization" Version="1.3.34-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Common" Version="1.3.34-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Compute" Version="1.3.34-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Graph.Rbac" Version="1.3.34-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.KeyVault" Version="1.3.34-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Monitor" Version="1.3.34-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Network" Version="1.3.34-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.PolicyInsights" Version="1.3.34-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.ResourceManager" Version="1.3.34-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Storage" Version="1.3.34-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Storage.Management" Version="1.3.34-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Strategies" Version="1.3.34-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Websites" Version="1.3.34-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Aks" Version="1.3.36-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Authentication.Abstractions" Version="1.3.36-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Authorization" Version="1.3.36-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Common" Version="1.3.36-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Compute" Version="1.3.36-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Graph.Rbac" Version="1.3.36-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.KeyVault" Version="1.3.36-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Monitor" Version="1.3.36-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Network" Version="1.3.36-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.PolicyInsights" Version="1.3.36-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.ResourceManager" Version="1.3.36-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Storage" Version="1.3.36-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Storage.Management" Version="1.3.36-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Strategies" Version="1.3.36-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Websites" Version="1.3.36-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Common.Share" Version="1.3.36-preview"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Azure.Core" Version="1.14.0"/>
Expand All @@ -35,7 +36,7 @@
<PackageReference Include="PowerShellStandard.Library" Version="5.1.0" PrivateAssets="All" />
</ItemGroup>
<PropertyGroup>
<StorageToolsPath>$(NugetPackageRoot)\microsoft.azure.powershell.storage\1.3.34-preview\tools\</StorageToolsPath>
<StorageToolsPath>$(NugetPackageRoot)\microsoft.azure.powershell.storage\1.3.36-preview\tools\</StorageToolsPath>
</PropertyGroup>
<ItemGroup Condition="'$(OmitJsonPackage)' != 'true'">
<PackageReference Include="Newtonsoft.Json" Version="10.0.3"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"AssemblyFileName","ClassName","Target","Severity","ProblemId","Description","Remediation"
"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"