Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions src/MySql/MySql.Autorest/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
[assembly: System.Reflection.AssemblyCopyrightAttribute("Copyright © Microsoft")]
[assembly: System.Reflection.AssemblyProductAttribute("Microsoft Azure PowerShell")]
[assembly: System.Reflection.AssemblyTitleAttribute("Microsoft Azure PowerShell - MySql")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.3.0")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.3.0")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.4.0")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.4.0")]
[assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)]
[assembly: System.CLSCompliantAttribute(false)]
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@

function Test-AzMySqlFlexibleServerConnect {
[OutputType([System.String])]
[CmdletBinding(DefaultParameterSetName='Test', PositionalBinding=$false)]
[CmdletBinding(DefaultParameterSetName = 'Test', PositionalBinding = $false)]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Description('Test out the connection to the database server')]
param(
[Parameter(ParameterSetName='Test', Mandatory, HelpMessage = 'The name of the server to connect.')]
[Parameter(ParameterSetName='TestAndQuery', Mandatory, HelpMessage = 'The name of the server to connect.')]
[Parameter(ParameterSetName = 'Test', Mandatory, HelpMessage = 'The name of the server to connect.')]
[Parameter(ParameterSetName = 'TestAndQuery', Mandatory, HelpMessage = 'The name of the server to connect.')]
[Alias('ServerName')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Path')]
[System.String]
${Name},

[Parameter(ParameterSetName='Test', Mandatory, HelpMessage = 'The name of the resource group that contains the resource, You can obtain this value from the Azure Resource Manager API or the portal.')]
[Parameter(ParameterSetName='TestAndQuery', Mandatory, HelpMessage = 'The name of the resource group that contains the resource, You can obtain this value from the Azure Resource Manager API or the portal.')]
[Parameter(ParameterSetName = 'Test', Mandatory, HelpMessage = 'The name of the resource group that contains the resource, You can obtain this value from the Azure Resource Manager API or the portal.')]
[Parameter(ParameterSetName = 'TestAndQuery', Mandatory, HelpMessage = 'The name of the resource group that contains the resource, You can obtain this value from the Azure Resource Manager API or the portal.')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Path')]
[System.String]
${ResourceGroupName},
Expand All @@ -35,14 +35,20 @@ function Test-AzMySqlFlexibleServerConnect {
[System.String]
${DatabaseName},

[Parameter(ParameterSetName='TestViaIdentityAndQuery', Mandatory, HelpMessage = 'The query for the database to test')]
[Parameter(ParameterSetName='TestAndQuery', Mandatory, HelpMessage = 'The query for the database to test')]
[Parameter(ParameterSetName = 'TestViaIdentityAndQuery', Mandatory, HelpMessage = 'The query for the database to test')]
[Parameter(ParameterSetName = 'TestAndQuery', Mandatory, HelpMessage = 'The query for the database to test')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Path')]
[System.String]
${QueryText},

[Parameter(ParameterSetName='TestViaIdentity', Mandatory, ValueFromPipeline, HelpMessage = 'The server to connect.')]
[Parameter(ParameterSetName='TestViaIdentityAndQuery', Mandatory, ValueFromPipeline, HelpMessage = 'The server to connect.')]
[Parameter(HelpMessage = 'The timeout in seconds for query execution. Valid range is 1-31536000 seconds.')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')]
[ValidateRange(1, 31536000)]
[System.Int32]
${Timeout},

[Parameter(ParameterSetName = 'TestViaIdentity', Mandatory, ValueFromPipeline, HelpMessage = 'The server to connect.')]
[Parameter(ParameterSetName = 'TestViaIdentityAndQuery', Mandatory, ValueFromPipeline, HelpMessage = 'The server to connect.')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Models.IMySqlIdentity]
${InputObject},
Expand Down Expand Up @@ -105,7 +111,7 @@ function Test-AzMySqlFlexibleServerConnect {
)

process {
if (!(Get-Module -ListAvailable -Name SimplySQL)){
if (!(Get-Module -ListAvailable -Name SimplySQL)) {
Write-Error "This cmdlet requires SimplySQL module. Please install the module first by running Install-Module -Name SimplySQL."
exit
}
Expand All @@ -117,6 +123,12 @@ function Test-AzMySqlFlexibleServerConnect {
$null = $PSBoundParameters.Remove('QueryText')
}

$TimeoutValue = 0
if ($PSBoundParameters.ContainsKey('Timeout')) {
$TimeoutValue = $PSBoundParameters.Timeout
$null = $PSBoundParameters.Remove('Timeout')
}

$DatabaseName = [string]::Empty
if ($PSBoundParameters.ContainsKey('DatabaseName')) {
$DatabaseName = $PSBoundParameters.DatabaseName
Expand All @@ -135,21 +147,32 @@ function Test-AzMySqlFlexibleServerConnect {
$Server = Az.MySql\Get-AzMySqlFlexibleServer @PSBoundParameters
$HostAddr = $Server.FullyQualifiedDomainName

if ($Server.NetworkPublicNetworkAccess -eq 'Disabled'){
if ($Server.NetworkPublicNetworkAccess -eq 'Disabled') {
Write-Host "You have to run the test cmdlet in the subnet your server is linked."
}
if ([string]::IsNullOrEmpty($AdministratorUserName)) {
$AdministratorUserName = $Server.AdministratorLogin
}

# Create PSCredential object for database connection
$SecurePassword = ConvertTo-SecureString -String $Password -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential($AdministratorUserName, $SecurePassword)

try {
if ([string]::IsNullOrEmpty($DatabaseName)){
Open-MySqlConnection -Database $DatabaseName -Server $HostAddr -UserName $AdministratorUserName -Password $Password -SSLMode Required -WarningAction 'silentlycontinue'
$DbToUse = if ([string]::IsNullOrEmpty($DatabaseName)) { "mysql" } else { $DatabaseName }
$OpenConnParams = @{
Database = $DbToUse
Server = $HostAddr
Credential = $Credential
SSLMode = 'Required'
WarningAction = 'SilentlyContinue'
}
else {
Open-MySqlConnection -Database "mysql" -Server $HostAddr -UserName $AdministratorUserName -Password $Password -SSLMode Required -WarningAction 'silentlycontinue'
if ($TimeoutValue -gt 0) {
$OpenConnParams['CommandTimeout'] = $TimeoutValue
}
} catch {
Open-MySqlConnection @OpenConnParams
}
catch {
Write-Host $_.Exception.GetType().FullName
Write-Host $_.Exception.Message
exit
Expand Down
25 changes: 21 additions & 4 deletions src/MySql/MySql.Autorest/docs/Test-AzMySqlFlexibleServerConnect.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,27 @@ Test out the connection to the database server
```
Test-AzMySqlFlexibleServerConnect -Name <String> -ResourceGroupName <String>
-AdministratorLoginPassword <SecureString> [-DatabaseName <String>] [-AdministratorUserName <String>]
[-DefaultProfile <PSObject>] [<CommonParameters>]
[-Timeout <Int32>] [-DefaultProfile <PSObject>] [<CommonParameters>]
```

### TestAndQuery
```
Test-AzMySqlFlexibleServerConnect -Name <String> -QueryText <String> -ResourceGroupName <String>
-AdministratorLoginPassword <SecureString> [-DatabaseName <String>] [-AdministratorUserName <String>]
[-DefaultProfile <PSObject>] [<CommonParameters>]
[-Timeout <Int32>] [-DefaultProfile <PSObject>] [<CommonParameters>]
```

### TestViaIdentity
```
Test-AzMySqlFlexibleServerConnect -AdministratorLoginPassword <SecureString> -InputObject <IMySqlIdentity>
[-DatabaseName <String>] [-AdministratorUserName <String>] [-DefaultProfile <PSObject>] [<CommonParameters>]
[-DatabaseName <String>] [-AdministratorUserName <String>] [-Timeout <Int32>] [-DefaultProfile <PSObject>]
[<CommonParameters>]
```

### TestViaIdentityAndQuery
```
Test-AzMySqlFlexibleServerConnect -QueryText <String> -AdministratorLoginPassword <SecureString>
-InputObject <IMySqlIdentity> [-DatabaseName <String>] [-AdministratorUserName <String>]
-InputObject <IMySqlIdentity> [-DatabaseName <String>] [-AdministratorUserName <String>] [-Timeout <Int32>]
[-DefaultProfile <PSObject>] [<CommonParameters>]
```

Expand Down Expand Up @@ -225,6 +226,22 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -Timeout
The timeout in seconds for query execution.
Valid range is 1-31536000 seconds.

```yaml
Type: System.Int32
Parameter Sets: (All)
Aliases:

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

Expand Down
2 changes: 1 addition & 1 deletion src/MySql/MySql.Autorest/generate-info.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"generate_Id": "12ad3b53-39f6-4285-b94f-1f77795eecb8"
"generate_Id": "0fd19a8b-c643-4d30-bdff-b0e6c750101b"
}
28 changes: 14 additions & 14 deletions src/MySql/MySql.sln
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MySql", "MySql\MySql.csproj
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MySql.Autorest", "MySql.Autorest", "{3FAB33A8-DCB3-1E46-A31E-A4F2684A642B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Az.MySql", "..\..\generated\MySql\MySql.Autorest\Az.MySql.csproj", "{A4A51B9D-DC53-4905-BF5F-5CF681424D4C}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Az.MySql", "..\..\generated\MySql\MySql.Autorest\Az.MySql.csproj", "{3694AB8D-4607-4BDC-8469-92572496436A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -117,18 +117,18 @@ Global
{286CC291-268F-4E04-85A8-1794BAAAF876}.Release|x64.Build.0 = Release|Any CPU
{286CC291-268F-4E04-85A8-1794BAAAF876}.Release|x86.ActiveCfg = Release|Any CPU
{286CC291-268F-4E04-85A8-1794BAAAF876}.Release|x86.Build.0 = Release|Any CPU
{A4A51B9D-DC53-4905-BF5F-5CF681424D4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A4A51B9D-DC53-4905-BF5F-5CF681424D4C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A4A51B9D-DC53-4905-BF5F-5CF681424D4C}.Debug|x64.ActiveCfg = Debug|Any CPU
{A4A51B9D-DC53-4905-BF5F-5CF681424D4C}.Debug|x64.Build.0 = Debug|Any CPU
{A4A51B9D-DC53-4905-BF5F-5CF681424D4C}.Debug|x86.ActiveCfg = Debug|Any CPU
{A4A51B9D-DC53-4905-BF5F-5CF681424D4C}.Debug|x86.Build.0 = Debug|Any CPU
{A4A51B9D-DC53-4905-BF5F-5CF681424D4C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A4A51B9D-DC53-4905-BF5F-5CF681424D4C}.Release|Any CPU.Build.0 = Release|Any CPU
{A4A51B9D-DC53-4905-BF5F-5CF681424D4C}.Release|x64.ActiveCfg = Release|Any CPU
{A4A51B9D-DC53-4905-BF5F-5CF681424D4C}.Release|x64.Build.0 = Release|Any CPU
{A4A51B9D-DC53-4905-BF5F-5CF681424D4C}.Release|x86.ActiveCfg = Release|Any CPU
{A4A51B9D-DC53-4905-BF5F-5CF681424D4C}.Release|x86.Build.0 = Release|Any CPU
{3694AB8D-4607-4BDC-8469-92572496436A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3694AB8D-4607-4BDC-8469-92572496436A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3694AB8D-4607-4BDC-8469-92572496436A}.Debug|x64.ActiveCfg = Debug|Any CPU
{3694AB8D-4607-4BDC-8469-92572496436A}.Debug|x64.Build.0 = Debug|Any CPU
{3694AB8D-4607-4BDC-8469-92572496436A}.Debug|x86.ActiveCfg = Debug|Any CPU
{3694AB8D-4607-4BDC-8469-92572496436A}.Debug|x86.Build.0 = Debug|Any CPU
{3694AB8D-4607-4BDC-8469-92572496436A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3694AB8D-4607-4BDC-8469-92572496436A}.Release|Any CPU.Build.0 = Release|Any CPU
{3694AB8D-4607-4BDC-8469-92572496436A}.Release|x64.ActiveCfg = Release|Any CPU
{3694AB8D-4607-4BDC-8469-92572496436A}.Release|x64.Build.0 = Release|Any CPU
{3694AB8D-4607-4BDC-8469-92572496436A}.Release|x86.ActiveCfg = Release|Any CPU
{3694AB8D-4607-4BDC-8469-92572496436A}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -140,6 +140,6 @@ Global
{BA5D2B5D-7F4D-4A92-B035-8F737578F3BC} = {2FFC8559-B8D4-4C7B-8B15-AEECEFA2F290}
{9AD18BB2-11C1-419A-91EA-1EA71A275200} = {2FFC8559-B8D4-4C7B-8B15-AEECEFA2F290}
{A5A6C5E0-EC4D-44BA-8C5A-2D6CAC21D861} = {2FFC8559-B8D4-4C7B-8B15-AEECEFA2F290}
{A4A51B9D-DC53-4905-BF5F-5CF681424D4C} = {3FAB33A8-DCB3-1E46-A31E-A4F2684A642B}
{3694AB8D-4607-4BDC-8469-92572496436A} = {3FAB33A8-DCB3-1E46-A31E-A4F2684A642B}
EndGlobalSection
EndGlobal
12 changes: 6 additions & 6 deletions src/MySql/MySql/Az.MySql.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: Microsoft Corporation
#
# Generated on: 5/28/2025
# Generated on: 6/27/2025
#

@{
Expand Down Expand Up @@ -51,16 +51,16 @@ DotNetFrameworkVersion = '4.7.2'
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(@{ModuleName = 'Az.Accounts'; ModuleVersion = '5.0.2'; })
RequiredModules = @(@{ModuleName = 'Az.Accounts'; ModuleVersion = '5.1.1'; })

# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = 'MySql.Autorest/bin/Az.MySql.private.dll'

# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()
ScriptsToProcess = @()

# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()
TypesToProcess = @()

# Format files (.ps1xml) to be loaded when importing this module
FormatsToProcess = 'MySql.Autorest/Az.MySql.format.ps1xml'
Expand Down Expand Up @@ -123,7 +123,7 @@ PrivateData = @{
PSData = @{

# Tags applied to this module. These help with module discovery in online galleries.
Tags = 'Azure','ResourceManager','ARM','PSModule','MySql'
Tags = 'Azure', 'ResourceManager', 'ARM', 'PSModule', 'MySql'

# A URL to the license for this module.
LicenseUri = 'https://aka.ms/azps-license'
Expand All @@ -148,7 +148,7 @@ PrivateData = @{

} # End of PSData hashtable

} # End of PrivateData hashtable
} # End of PrivateData hashtable

# HelpInfo URI of this module
# HelpInfoURI = ''
Expand Down
2 changes: 2 additions & 0 deletions src/MySql/MySql/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
- Additional information about change #1
-->
## Upcoming Release
- Aligned with SimplySql, use a PSCredential object instead of UserName/Password parameters when calling Open-MySQLConnection
- Introduced a Timeout value when running Test-AzMySqlFlexibleServerConnect with long running query

## Version 1.4.0
- Enhanced `Restore-AzMySqlFlexibleServer` functionality with GeoRestore support
Expand Down
2 changes: 1 addition & 1 deletion src/MySql/MySql/help/New-AzMySqlFlexibleServer.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Creates a new MySQL flexible server.

### Example 1: Create a new MySql flexible server with arguments
```powershell
$password = ConvertTo-SecureString -String <YourPassword> -Force -AsPlainText
$password = ConvertTo-SecureString -String "1234" -Force -AsPlainText
New-AzMySqlFlexibleServer -Name mysql-test -ResourceGroupName PowershellMySqlTest -Location eastus -AdministratorUserName mysqltest -AdministratorLoginPassword $password -Sku Standard_D2ds_v4 -SkuTier Burstable -Version 12 -StorageInMb 20480 -PublicAccess none -Zone 1 -BackupRetentionDay 10 -StorageAutogrow Enabled -Iops 500 -HighAvailability ZoneRedundant
```

Expand Down
34 changes: 26 additions & 8 deletions src/MySql/MySql/help/Test-AzMySqlFlexibleServerConnect.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,31 @@ Test out the connection to the database server
### Test (Default)
```
Test-AzMySqlFlexibleServerConnect -Name <String> -ResourceGroupName <String> [-DatabaseName <String>]
-AdministratorLoginPassword <SecureString> [-AdministratorUserName <String>] [-DefaultProfile <PSObject>]
[<CommonParameters>]
-AdministratorLoginPassword <SecureString> [-Timeout <Int32>] [-AdministratorUserName <String>]
[-DefaultProfile <PSObject>] [<CommonParameters>]
```

### TestAndQuery
```
Test-AzMySqlFlexibleServerConnect -Name <String> -ResourceGroupName <String> [-DatabaseName <String>]
-QueryText <String> -AdministratorLoginPassword <SecureString> [-AdministratorUserName <String>]
[-DefaultProfile <PSObject>] [<CommonParameters>]
-QueryText <String> -AdministratorLoginPassword <SecureString> [-Timeout <Int32>]
[-AdministratorUserName <String>] [-DefaultProfile <PSObject>]
[<CommonParameters>]
```

### TestViaIdentityAndQuery
```
Test-AzMySqlFlexibleServerConnect [-DatabaseName <String>] -QueryText <String>
-AdministratorLoginPassword <SecureString> [-AdministratorUserName <String>] -InputObject <IMySqlIdentity>
[-DefaultProfile <PSObject>] [<CommonParameters>]
-AdministratorLoginPassword <SecureString> [-Timeout <Int32>] [-AdministratorUserName <String>]
-InputObject <IMySqlIdentity> [-DefaultProfile <PSObject>]
[<CommonParameters>]
```

### TestViaIdentity
```
Test-AzMySqlFlexibleServerConnect [-DatabaseName <String>] -AdministratorLoginPassword <SecureString>
[-AdministratorUserName <String>] -InputObject <IMySqlIdentity> [-DefaultProfile <PSObject>]
[<CommonParameters>]
[-Timeout <Int32>] [-AdministratorUserName <String>] -InputObject <IMySqlIdentity>
[-DefaultProfile <PSObject>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -226,6 +228,22 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -Timeout
The timeout in seconds for query execution.
Valid range is 1-31536000 seconds.

```yaml
Type: System.Int32
Parameter Sets: (All)
Aliases:

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

Expand Down