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

Changed MySql New-AzMySqlFlexibleServer cmdlet and Added Get-AzMySqlFlexibleServerLocationBasedCapability #13717

Merged
merged 55 commits into from
Jan 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
d9d5efc
Generate flexible server cmdlets (#13269)
msJinLei Oct 26, 2020
f4544d5
test commit with server mgmt md files
DaeunYim Oct 27, 2020
2959642
cmdlet design draft
DaeunYim Oct 27, 2020
417cd56
fixed errors for mysql md files
DaeunYim Oct 28, 2020
d15f568
fixed errors for mysql md files
DaeunYim Oct 28, 2020
cb87cf9
fixing mistakes
DaeunYim Oct 29, 2020
b4e271b
resolved comments
DaeunYim Nov 2, 2020
38ed225
mysql cmdlets customization verified
DaeunYim Nov 6, 2020
e72cbc1
mysql modified
DaeunYim Nov 7, 2020
a8f6afc
postgres customized cmdlets and readme
DaeunYim Nov 7, 2020
04c3cd3
mysql postgres customized cmdlets and docs
DaeunYim Nov 9, 2020
eee9270
initial commit for mysql pg module
DaeunYim Nov 11, 2020
a83d728
mysql test success
DaeunYim Nov 12, 2020
18fb307
pg module
DaeunYim Nov 12, 2020
db2fb10
postgresql cmdlet update test fixed
DaeunYim Nov 12, 2020
6c60dbf
example document fixed
DaeunYim Nov 13, 2020
81b81c0
Revert "example document fixed"
DaeunYim Nov 13, 2020
07ece3b
align single server test with flexible server
DaeunYim Nov 13, 2020
cb3eef1
docs fixed
DaeunYim Nov 16, 2020
2f8e9c4
docs files moved from exports to upper folder
DaeunYim Nov 16, 2020
5b782f0
typo fixed
DaeunYim Nov 17, 2020
3f286b1
revert postgresql
DaeunYim Nov 20, 2020
0b0c3ce
configuration fixed
DaeunYim Nov 20, 2020
2f82cee
cred scan added
DaeunYim Nov 24, 2020
90a07d9
cred scan issue resolved
DaeunYim Nov 24, 2020
19ad16d
Regenerate doc of the MySql
msJinLei Nov 25, 2020
b192981
comments resolved
DaeunYim Nov 26, 2020
a69a8a7
initial network commit
DaeunYim Nov 30, 2020
82a0ba6
create customization
DaeunYim Dec 3, 2020
a95fd14
test record
DaeunYim Dec 11, 2020
f16d462
pulled generation repo
DaeunYim Dec 11, 2020
a199dec
utils issue fixed
DaeunYim Dec 11, 2020
82c4deb
test ci fix
DaeunYim Dec 11, 2020
bdfaf15
CI failure fix
DaeunYim Dec 11, 2020
5c9e71e
testing CI fix
DaeunYim Dec 11, 2020
88aefad
CI test faliure fixing
DaeunYim Dec 11, 2020
756e598
CI test fix final
DaeunYim Dec 12, 2020
bbb8d73
new server doc fix
DaeunYim Dec 14, 2020
857c504
mysql comments resolved
DaeunYim Dec 21, 2020
201a9ab
comments resolved
DaeunYim Dec 21, 2020
ef97b8f
CI test fixed
DaeunYim Dec 22, 2020
83017f3
Merge branch 'generation' into daeunyim/mysql-create
DaeunYim Dec 22, 2020
3d85e3d
Remove skip in test cases
msJinLei Dec 22, 2020
2e11308
testing env config fixed
DaeunYim Dec 29, 2020
20c7caf
testing env config fixed
DaeunYim Dec 29, 2020
d35fc8c
test fixed with flexible arguments
DaeunYim Dec 30, 2020
021546d
Merge branch 'generation' into mysql-create
DaeunYim Dec 30, 2020
786a5a7
pulled upstream generation
DaeunYim Dec 30, 2020
9aec809
location changed from westus2 to eastus2euap
DaeunYim Dec 30, 2020
cee6ccd
resource group name changed
DaeunYim Dec 31, 2020
43fcdeb
customized server object for creation cmdlet
DaeunYim Jan 4, 2021
8e5d270
Update FlexibleServer.cs
DaeunYim Jan 5, 2021
a746aad
dynamically assign a server name for live testing
DaeunYim Jan 5, 2021
75ceac8
dynamically assign live test variables
DaeunYim Jan 6, 2021
3ebe5c8
if else case consistent
DaeunYim Jan 6, 2021
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
28 changes: 28 additions & 0 deletions src/MySql/custom/FlexibleServer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace Microsoft.Azure.PowerShell.Cmdlets.MySql.Models.Api20200701Preview
{
using static Microsoft.Azure.PowerShell.Cmdlets.MySql.Runtime.Extensions;
using System.Security;

/// <summary>Represents a server.</summary>
public partial class ServerAutoGenerated
{
private SecureString _SecuredPassword;
// <summary> The user password in secure string. Convert the secure string into plain text if necessary. </summary>
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Origin(Microsoft.Azure.PowerShell.Cmdlets.MySql.PropertyOrigin.Inlined)]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.DoNotFormat]
public SecureString SecuredPassword {get => this._SecuredPassword; set => this._SecuredPassword = value;}

private string _FirewallRuleName;
// <summary> The name of the firewall rule of the server </summary>
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Origin(Microsoft.Azure.PowerShell.Cmdlets.MySql.PropertyOrigin.Inlined)]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.DoNotFormat]
public string FirewallRuleName {get => this._FirewallRuleName; set => this._FirewallRuleName = value;}

private string _DatabaseName;
// <summary> The name of the default database created for the server </summary>
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Origin(Microsoft.Azure.PowerShell.Cmdlets.MySql.PropertyOrigin.Inlined)]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.DoNotFormat]
public string DatabaseName {get => this._DatabaseName; set => this._DatabaseName = value;}

}
}
2 changes: 1 addition & 1 deletion src/MySql/custom/Get-AzMySqlConnectionString.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function Get-AzMySqlConnectionString {
[System.String]
${SubscriptionId},

[Parameter(ParameterSetName='GetViaIdentity', Mandatory, ValueFromPipeline, HelpMessage = 'The source server object to create replica from.')]
[Parameter(ParameterSetName='GetViaIdentity', Mandatory, ValueFromPipeline, HelpMessage = 'Name of the server')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Models.Api20171201.IServer]
${InputObject},
Expand Down
144 changes: 144 additions & 0 deletions src/MySql/custom/Get-AzMySqlFlexibleServerConnectionString.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# ----------------------------------------------------------------------------------
#
# 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.
# ----------------------------------------------------------------------------------

<#
.Synopsis
Get the connection string according to client connection provider.
.Description
Get the connection string according to client connection provider.
#>

function Get-AzMySqlFlexibleServerConnectionString {
[OutputType([System.String])]
[CmdletBinding(DefaultParameterSetName='Get', PositionalBinding=$false)]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Description('Get the connection string according to client connection provider.')]
param(
[Parameter(ParameterSetName='Get', Mandatory, HelpMessage = 'The name of the server.')]
[Alias('ServerName')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Path')]
[System.String]
${Name},

[Parameter(ParameterSetName='Get', 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},

[Parameter(ParameterSetName='Get', HelpMessage='The subscription ID that identifies an Azure subscription.')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
[System.String]
${SubscriptionId},

[Parameter(Mandatory, HelpMessage = 'Client connection provider.')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Path')]
[Validateset('ADO.NET', 'JDBC', 'Node.js', 'PHP', 'Python', 'Ruby', 'WebApp')]
[System.String]
${Client},

[Parameter(ParameterSetName='GetViaIdentity', Mandatory, ValueFromPipeline, HelpMessage = 'Name of the server')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Models.IMySqlIdentity]
${InputObject},

[Parameter(HelpMessage = 'The credentials, account, tenant, and subscription used for communication with Azure.')]
[Alias('AzureRMContext', 'AzureCredential')]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Azure')]
[System.Management.Automation.PSObject]
${DefaultProfile},

[Parameter(DontShow, HelpMessage = 'Wait for .NET debugger to attach.')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
${Break},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Runtime.SendAsyncStep[]]
# SendAsync Pipeline Steps to be appended to the front of the pipeline.
${HttpPipelineAppend},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Runtime.SendAsyncStep[]]
# SendAsync Pipeline Steps to be prepended to the front of the pipeline.
${HttpPipelinePrepend},

[Parameter(DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')]
[System.Uri]
# The URI for the proxy server to use.
${Proxy},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')]
[System.Management.Automation.PSCredential]
# Credentials for a proxy server to use for the remote call.
${ProxyCredential},

[Parameter(DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
# Use the default credentials for the proxy.
${ProxyUseDefaultCredentials}
)
DaeunYim marked this conversation as resolved.
Show resolved Hide resolved

process {
function GetConnectionStringSslPart {
param(
[Parameter()]
[string]
${Client},
[Parameter()]
[string]
${SslEnforcement}
)
$SslEnforcementTemplateMap = @{
'ADO.NET' = 'SslMode=MySqlSslMode.Required;SslCa="{ca-cert filename}"'
'JDBC' = '?useSSL=true'
'Node.js' = ', ssl:{ca:fs.readFileSync({ca-cert filename})}'
'PHP' = 'mysqli_ssl_set($con, NULL, NULL, {ca-cert filename}, NULL, NULL);'
'Python' = ', ssl_ca={ca-cert filename}, ssl_verify_cert=true'
'Ruby' = ', sslca:{ca-cert filename}, sslverify:false, sslcipher:"AES256-SHA"'
'WebApp' = ''
}
if ($SslEnforcement -eq 'Enabled') {
return $SslEnforcementTemplateMap[$Client]
}
return ''
}

$clientConnection = $PSBoundParameters['Client']
$null = $PSBoundParameters.Remove('Client')
$mySqlServer = Az.MySql\Get-AzMySqlFlexibleServer @PSBoundParameters
$DBHost = $mySqlServer.FullyQualifiedDomainName
$DBPort = 3306
$adminName = $mySqlServer.AdministratorLogin
$SslConnectionString = GetConnectionStringSslPart -Client $clientConnection -SslEnforcement $mySqlServer.SslEnforcement
$ConnectionStringMap = @{
'ADO.NET' = "Server=${DBHost}; Port=${DBPort}; Database={your_database}; UserID=${adminName}; Password={your_password}; $SslConnectionString"
'JDBC' = "String url =`"jdbc:mysql://${DBHost}:${DBPort}/{your_database}$SslConnectionString`"; myDbConn = DriverManager.getConnection(url, `"${adminName}`", {your_password});"
'Node.js' = "var conn = mysql.createConnection({host: `"${DBHost}`", user: `"${adminName}`", password: {your_password}, database: {your_database}, port: ${DBPort}$SslConnectionString});"
'PHP' = "`$con=mysqli_init();$SslConnectionString mysqli_real_connect(`$con, `"${DBHost}`", `"${adminName}`", {your_password}, {your_database}, ${DBPort});"
'Python' = "cnx = mysql.connector.connect(user=`"${adminName}`", password={your_password}, host=`"${DBHost}`", port=${DBPort}, database={your_database}$SslConnectionString)"
'Ruby' = "client = Mysql2::Client.new(username: `"${adminName}`", password: {your_password}, database: {your_database}, host: `"${DBHost}`", port: ${DBPort}$SslConnectionString)"
}
return $ConnectionStringMap[$Client]
}
}

119 changes: 119 additions & 0 deletions src/MySql/custom/Get-AzMySqlFlexibleServerLocationBasedCapability.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# ----------------------------------------------------------------------------------
#
# 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.
# ----------------------------------------------------------------------------------

<#
.Synopsis
Get the available SKU information for the location
.Description
Get the available SKU information for the location
#>

function Get-AzMySqlFlexibleServerLocationBasedCapability {
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.MySql.Models.Api20200701Preview.ICapabilityProperties])]
[CmdletBinding(DefaultParameterSetName='List', PositionalBinding=$false)]
param(
[Parameter(Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Path')]
[System.String]
# The name of the location.
${Location},

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
[System.String[]]
# The ID of the target subscription.
${SubscriptionId},

[Parameter()]
[Alias('AzureRMContext', 'AzureCredential')]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Azure')]
[System.Management.Automation.PSObject]
# The credentials, account, tenant, and subscription used for communication with Azure.
${DefaultProfile},

[Parameter(DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
# Wait for .NET debugger to attach
${Break},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Runtime.SendAsyncStep[]]
# SendAsync Pipeline Steps to be appended to the front of the pipeline
${HttpPipelineAppend},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Runtime.SendAsyncStep[]]
# SendAsync Pipeline Steps to be prepended to the front of the pipeline
${HttpPipelinePrepend},

[Parameter(DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')]
[System.Uri]
# The URI for the proxy server to use
${Proxy},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')]
[System.Management.Automation.PSCredential]
# Credentials for a proxy server to use for the remote call
${ProxyCredential},

[Parameter(DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
# Use the default credentials for the proxy
${ProxyUseDefaultCredentials}
)

process {
try {
$PSBoundParameters.LocationName = $PSBoundParameters['Location']
$null = $PSBoundParameters.Remove('Location')

$Result = Az.MySql.internal\Get-AzMySqlFlexibleServerLocationBasedCapability @PSBoundParameters
Write-Host "Please refer to https://aka.ms/mysql-pricing for pricing details"
$SkusTiers = $Result[0].SupportedFlexibleServerEdition
$TableResult = @()

foreach ($Skus in $SkusTiers) {
$TierName = $Skus.Name
try {
$Keys = $Skus.SupportedServerVersion[0].SupportedVcore

foreach ($Key in $Keys) {
$NewEntry = New-Object -TypeName PSCustomObject -Property @{SKU=$Key.Name; Tier=$TierName; vCore=$Key.Vcore; Memory=$Key.SupportedMemoryPerVcoreMb}
$TableResult += $NewEntry
}
}
catch {
throw "No SKU info for this location"
}
}

return $TableResult


} catch {
throw
}
}
}
Loading