Skip to content

Commit

Permalink
[MySql] Add parameter MinimalTlsVersion for the cmdlets. (#13838)
Browse files Browse the repository at this point in the history
* [MySql] add parameter MinimalTlsVersion.

* [MySql] remove defaule value of mistslversion from the custom cmdlet.

* [MySql] delete Az.MySql-TestResults.xml, because The file is uploaded unnecessarily.

* [MySql] Write code for assgin value to the paramter MinimalTlsVersion.
  • Loading branch information
LucasYao93 authored Dec 29, 2020
1 parent e19e3f4 commit ee3c15d
Show file tree
Hide file tree
Showing 11 changed files with 389 additions and 416 deletions.
1 change: 1 addition & 0 deletions src/MySql/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
15 changes: 15 additions & 0 deletions src/MySql/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
bin
obj
.vs
generated
internal
exports
tools
custom/*.psm1
test/*-TestResults.xml
/*.ps1
/*.ps1xml
/*.psm1
/*.snk
/*.csproj
/*.nuspec
24 changes: 24 additions & 0 deletions src/MySql/Az.MySql.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@{
GUID = '0b8ac9f4-b926-4ac8-b73f-937a0d218521'
RootModule = './Az.MySql.psm1'
ModuleVersion = '0.1.0'
CompatiblePSEditions = 'Core', 'Desktop'
Author = 'Microsoft Corporation'
CompanyName = 'Microsoft Corporation'
Copyright = 'Microsoft Corporation. All rights reserved.'
Description = 'Microsoft Azure PowerShell: MySql cmdlets'
PowerShellVersion = '5.1'
DotNetFrameworkVersion = '4.7.2'
RequiredAssemblies = './bin/Az.MySql.private.dll'
FormatsToProcess = './Az.MySql.format.ps1xml'
FunctionsToExport = 'Get-AzMySqlConfiguration', 'Get-AzMySqlConnectionString', 'Get-AzMySqlFirewallRule', 'Get-AzMySqlFlexibleServer', 'Get-AzMySqlFlexibleServerConfiguration', 'Get-AzMySqlFlexibleServerDatabase', 'Get-AzMySqlFlexibleServerFirewallRule', 'Get-AzMySqlFlexibleServerReplica', 'Get-AzMySqlReplica', 'Get-AzMySqlServer', 'Get-AzMySqlVirtualNetworkRule', 'New-AzMySqlFirewallRule', 'New-AzMySqlFlexibleServer', 'New-AzMySqlFlexibleServerDatabase', 'New-AzMySqlFlexibleServerFirewallRule', 'New-AzMySqlFlexibleServerReplica', 'New-AzMySqlReplica', 'New-AzMySqlServer', 'New-AzMySqlVirtualNetworkRule', 'Remove-AzMySqlFirewallRule', 'Remove-AzMySqlFlexibleServer', 'Remove-AzMySqlFlexibleServerDatabase', 'Remove-AzMySqlFlexibleServerFirewallRule', 'Remove-AzMySqlServer', 'Remove-AzMySqlVirtualNetworkRule', 'Restart-AzMySqlFlexibleServer', 'Restart-AzMySqlServer', 'Restore-AzMySqlFlexibleServer', 'Restore-AzMySqlServer', 'Start-AzMySqlFlexibleServer', 'Stop-AzMySqlFlexibleServer', 'Update-AzMySqlConfiguration', 'Update-AzMySqlFirewallRule', 'Update-AzMySqlFlexibleServer', 'Update-AzMySqlFlexibleServerConfiguration', 'Update-AzMySqlFlexibleServerDatabase', 'Update-AzMySqlFlexibleServerFirewallRule', 'Update-AzMySqlServer', 'Update-AzMySqlVirtualNetworkRule', '*'
AliasesToExport = '*'
PrivateData = @{
PSData = @{
Tags = 'Azure', 'ResourceManager', 'ARM', 'PSModule', 'MySql'
LicenseUri = 'https://aka.ms/azps-license'
ProjectUri = 'https://github.com/Azure/azure-powershell'
ReleaseNotes = ''
}
}
}
12 changes: 12 additions & 0 deletions src/MySql/custom/New-AzMySqlServer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ function New-AzMySqlServer {
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Support.SslEnforcementEnum]
${SslEnforcement},

[Parameter(HelpMessage = 'Set the minimal TLS version for connections to server when SSL is enabled. Default is TLSEnforcementDisabled.accepted values: TLS1_0, TLS1_1, TLS1_2, TLSEnforcementDisabled.')]
[ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.MySql.Support.MinimalTlsVersionEnum])]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Support.MinimalTlsVersionEnum]
# Enforce a minimal Tls version for the server.
${MinimalTlsVersion},

[Parameter(HelpMessage = "Backup retention days for the server. Day count is between 7 and 35.")]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')]
[System.Int32]
Expand Down Expand Up @@ -177,6 +184,11 @@ function New-AzMySqlServer {
$Parameter.SslEnforcement = [Microsoft.Azure.PowerShell.Cmdlets.MySql.Support.SslEnforcementEnum]::Enable
}

if ($PSBoundParameters.ContainsKey('MinimalTlsVersion')) {
$Parameter.MinimalTlsVersion = $PSBoundParameters['MinimalTlsVersion']
$null = $PSBoundParameters.Remove('MinimalTlsVersion')
}

if ($PSBoundParameters.ContainsKey('BackupRetentionDay')) {
$Parameter.StorageProfileBackupRetentionDay = $PSBoundParameters['BackupRetentionDay']
$null = $PSBoundParameters.Remove('BackupRetentionDay')
Expand Down
7 changes: 7 additions & 0 deletions src/MySql/custom/Update-AzMySqlServer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ function Update-AzMySqlServer {
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Support.SslEnforcementEnum]
${SslEnforcement},

[Parameter(HelpMessage = 'Set the minimal TLS version for connections to server when SSL is enabled. Default is TLSEnforcementDisabled.accepted values: TLS1_0, TLS1_1, TLS1_2, TLSEnforcementDisabled.')]
[ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.MySql.Support.MinimalTlsVersionEnum])]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Support.MinimalTlsVersionEnum]
# Enforce a minimal Tls version for the server.
${MinimalTlsVersion},

[Parameter(HelpMessage='Backup retention days for the server. Day count is between 7 and 35.')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')]
[System.Int32]
Expand Down
2 changes: 1 addition & 1 deletion src/MySql/docs/Az.MySql.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
Module Name: Az.MySql
Module Guid: 6fb456f8-3967-40b0-a0af-3be8e13ae017
Module Guid: 0b8ac9f4-b926-4ac8-b73f-937a0d218521
Download Help Link: https://docs.microsoft.com/en-us/powershell/module/az.mysql
Help Version: 1.0.0.0
Locale: en-US
Expand Down
22 changes: 19 additions & 3 deletions src/MySql/docs/New-AzMySqlServer.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ Creates a new server.
New-AzMySqlServer -Name <String> -ResourceGroupName <String> -AdministratorLoginPassword <SecureString>
-AdministratorUserName <String> -Location <String> -Sku <String> [-SubscriptionId <String>]
[-BackupRetentionDay <Int32>] [-GeoRedundantBackup <GeoRedundantBackup>]
[-SslEnforcement <SslEnforcementEnum>] [-StorageAutogrow <StorageAutogrow>] [-StorageInMb <Int32>]
[-Tag <Hashtable>] [-Version <ServerVersion>] [-DefaultProfile <PSObject>] [-AsJob] [-NoWait] [-Confirm]
[-WhatIf] [<CommonParameters>]
[-MinimalTlsVersion <MinimalTlsVersionEnum>] [-SslEnforcement <SslEnforcementEnum>]
[-StorageAutogrow <StorageAutogrow>] [-StorageInMb <Int32>] [-Tag <Hashtable>] [-Version <ServerVersion>]
[-DefaultProfile <PSObject>] [-AsJob] [-NoWait] [-Confirm] [-WhatIf] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -148,6 +148,22 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -MinimalTlsVersion
Set the minimal TLS version for connections to server when SSL is enabled.
Default is TLSEnforcementDisabled.accepted values: TLS1_0, TLS1_1, TLS1_2, TLSEnforcementDisabled.
```yaml
Type: Microsoft.Azure.PowerShell.Cmdlets.MySql.Support.MinimalTlsVersionEnum
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Name
The name of the server.
Expand Down
33 changes: 25 additions & 8 deletions src/MySql/docs/Update-AzMySqlServer.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,20 @@ Use Update-AzMySqlConfiguration instead if you want update server parameters suc
### UpdateExpanded (Default)
```
Update-AzMySqlServer -Name <String> -ResourceGroupName <String> [-SubscriptionId <String>]
[-AdministratorLoginPassword <SecureString>] [-BackupRetentionDay <Int32>] [-ReplicationRole <String>]
[-Sku <String>] [-SkuCapacity <Int32>] [-SkuFamily <String>] [-SkuTier <SkuTier>]
[-SslEnforcement <SslEnforcementEnum>] [-StorageAutogrow <StorageAutogrow>] [-StorageInMb <Int32>]
[-Tag <Hashtable>] [-DefaultProfile <PSObject>] [-AsJob] [-NoWait] [-Confirm] [-WhatIf] [<CommonParameters>]
[-AdministratorLoginPassword <SecureString>] [-BackupRetentionDay <Int32>]
[-MinimalTlsVersion <MinimalTlsVersionEnum>] [-ReplicationRole <String>] [-Sku <String>]
[-SkuCapacity <Int32>] [-SkuFamily <String>] [-SkuTier <SkuTier>] [-SslEnforcement <SslEnforcementEnum>]
[-StorageAutogrow <StorageAutogrow>] [-StorageInMb <Int32>] [-Tag <Hashtable>] [-DefaultProfile <PSObject>]
[-AsJob] [-NoWait] [-Confirm] [-WhatIf] [<CommonParameters>]
```

### UpdateViaIdentityExpanded
```
Update-AzMySqlServer -InputObject <IMySqlIdentity> [-AdministratorLoginPassword <SecureString>]
[-BackupRetentionDay <Int32>] [-ReplicationRole <String>] [-Sku <String>] [-SkuCapacity <Int32>]
[-SkuFamily <String>] [-SkuTier <SkuTier>] [-SslEnforcement <SslEnforcementEnum>]
[-StorageAutogrow <StorageAutogrow>] [-StorageInMb <Int32>] [-Tag <Hashtable>] [-DefaultProfile <PSObject>]
[-AsJob] [-NoWait] [-Confirm] [-WhatIf] [<CommonParameters>]
[-BackupRetentionDay <Int32>] [-MinimalTlsVersion <MinimalTlsVersionEnum>] [-ReplicationRole <String>]
[-Sku <String>] [-SkuCapacity <Int32>] [-SkuFamily <String>] [-SkuTier <SkuTier>]
[-SslEnforcement <SslEnforcementEnum>] [-StorageAutogrow <StorageAutogrow>] [-StorageInMb <Int32>]
[-Tag <Hashtable>] [-DefaultProfile <PSObject>] [-AsJob] [-NoWait] [-Confirm] [-WhatIf] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -140,6 +141,22 @@ Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```
### -MinimalTlsVersion
Set the minimal TLS version for connections to server when SSL is enabled.
Default is TLSEnforcementDisabled.accepted values: TLS1_0, TLS1_1, TLS1_2, TLSEnforcementDisabled.
```yaml
Type: Microsoft.Azure.PowerShell.Cmdlets.MySql.Support.MinimalTlsVersionEnum
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Name
The name of the server.
Expand Down
58 changes: 58 additions & 0 deletions src/MySql/how-to.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# How-To
This document describes how to develop for `Az.MySql`.

## Building `Az.MySql`
To build, run the `build-module.ps1` at the root of the module directory. This will generate the proxy script cmdlets that are the cmdlets being exported by this module. After the build completes, the proxy script cmdlets will be output to the `exports` folder. To read more about the proxy script cmdlets, look at the [readme.md](exports/readme.md) in the `exports` folder.

## Creating custom cmdlets
To add cmdlets that were not generated by the REST specification, use the `custom` folder. This folder allows you to add handwritten `.ps1` and `.cs` files. Currently, we support using `.ps1` scripts as new cmdlets or as additional low-level variants (via `ParameterSet`), and `.cs` files as low-level (variants) cmdlets that the exported script cmdlets call. We do not support exporting any `.cs` (dll) cmdlets directly. To read more about custom cmdlets, look at the [readme.md](custom/readme.md) in the `custom` folder.

## Generating documentation
To generate documentation, the process is now integrated into the `build-module.ps1` script. If you don't want to run this process as part of `build-module.ps1`, you can provide the `-NoDocs` switch. If you want to run documentation generation after the build process, you may still run the `generate-help.ps1` script. Overall, the process will look at the documentation comments in the generated and custom cmdlets and types, and create `.md` files into the `docs` folder. Additionally, this pulls in any examples from the `examples` folder and adds them to the generated help markdown documents. To read more about examples, look at the [readme.md](examples/readme.md) in the `examples` folder. To read more about documentation, look at the [readme.md](docs/readme.md) in the `docs` folder.

## Testing `Az.MySql`
To test the cmdlets, we use [Pester](https://github.com/pester/Pester). Tests scripts (`.ps1`) should be added to the `test` folder. To execute the Pester tests, run the `test-module.ps1` script. This will run all tests in `playback` mode within the `test` folder. To read more about testing cmdlets, look at the [readme.md](examples/readme.md) in the `examples` folder.

## Packing `Az.MySql`
To pack `Az.MySql` for distribution, run the `pack-module.ps1` script. This will take the contents of multiple directories and certain root-folder files to create a `.nupkg`. The structure of the `.nupkg` is created so it can be loaded part of a [PSRepository](https://docs.microsoft.com/en-us/powershell/module/powershellget/register-psrepository). Additionally, this package is in a format for distribution to the [PSGallery](https://www.powershellgallery.com/). For signing an Azure module, please contact the [Azure PowerShell](https://github.com/Azure/azure-powershell) team.

## Module Script Details
There are multiple scripts created for performing different actions for developing `Az.MySql`.
- `build-module.ps1`
- Builds the module DLL (`./bin/Az.MySql.private.dll`), creates the exported cmdlets and documentation, generates custom cmdlet test stubs and exported cmdlet example stubs, and updates `./Az.MySql.psd1` with Azure profile information.
- **Parameters**: [`Switch` parameters]
- `-Run`: After building, creates an isolated PowerShell session and loads `Az.MySql`.
- `-Test`: After building, runs the `Pester` tests defined in the `test` folder.
- `-Docs`: After building, generates the Markdown documents for the modules into the `docs` folder.
- `-Pack`: After building, packages the module into a `.nupkg`.
- `-Code`: After building, opens a VSCode window with the module's directory and runs (see `-Run`) the module.
- `-Release`: Builds the module in `Release` configuration (as opposed to `Debug` configuration).
- `-NoDocs`: Supresses writing the documentation markdown files as part of the cmdlet exporting process.
- `-Debugger`: Used when attaching the debugger in Visual Studio to the PowerShell session, and running the build process without recompiling the DLL. This suppresses running the script as an isolated process.
- `run-module.ps1`
- Creates an isolated PowerShell session and loads `Az.MySql` into the session.
- Same as `-Run` in `build-module.ps1`.
- **Parameters**: [`Switch` parameters]
- `-Code`: Opens a VSCode window with the module's directory.
- Same as `-Code` in `build-module.ps1`.
- `generate-help.ps1`
- Generates the Markdown documents for the modules into the `docs` folder.
- Same as `-Docs` in `build-module.ps1`.
- `test-module.ps1`
- Runs the `Pester` tests defined in the `test` folder.
- Same as `-Test` in `build-module.ps1`.
- `pack-module.ps1`
- Packages the module into a `.nupkg` for distribution.
- Same as `-Pack` in `build-module.ps1`.
- `generate-help.ps1`
- Generates the Markdown documents for the modules into the `docs` folder.
- Same as `-Docs` in `build-module.ps1`.
- This process is now integrated into `build-module.ps1` automatically. To disable, use `-NoDocs` when running `build-module.ps1`.
- `export-surface.ps1`
- Generates Markdown documents for both the cmdlet surface and the model (class) surface of the module.
- These files are placed into the `resources` folder.
- Used for investigating the surface of your module. These are *not* documentation for distribution.
- `check-dependencies.ps1`
- Used in `run-module.ps1` and `test-module.ps1` to verify dependent modules are available to run those tasks.
- It will download local (within the module's directory structure) versions of those modules as needed.
- This script *does not* need to be ran by-hand.
Loading

0 comments on commit ee3c15d

Please sign in to comment.