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
6 changes: 0 additions & 6 deletions src/MySql/Az.MySql.format.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -648,9 +648,6 @@
<TableColumnHeader>
<Label>SkuName</Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>SkuSize</Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>SkuTier</Label>
</TableColumnHeader>
Expand Down Expand Up @@ -679,9 +676,6 @@
<TableColumnItem>
<PropertyName>SkuName</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>SkuSize</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>SkuTier</PropertyName>
</TableColumnItem>
Expand Down
6 changes: 3 additions & 3 deletions src/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/9/2020
# Generated on: 8/12/2020
#

@{
Expand Down Expand Up @@ -72,7 +72,7 @@ FormatsToProcess = './Az.MySql.format.ps1xml'
FunctionsToExport = 'Get-AzMySqlConfiguration', 'Get-AzMySqlConnectionString',
'Get-AzMySqlFirewallRule', 'Get-AzMySqlReplica', 'Get-AzMySqlServer',
'Get-AzMySqlVirtualNetworkRule', 'New-AzMySqlFirewallRule',
'New-AzMySqlServer', 'New-AzMySqlServerReplica',
'New-AzMySqlReplica', 'New-AzMySqlServer',
'New-AzMySqlVirtualNetworkRule', 'Remove-AzMySqlFirewallRule',
'Remove-AzMySqlServer', 'Remove-AzMySqlVirtualNetworkRule',
'Restart-AzMySqlServer', 'Restore-AzMySqlServer',
Expand Down Expand Up @@ -115,7 +115,7 @@ PrivateData = @{
# IconUri = ''

# ReleaseNotes of this module
ReleaseNotes = '* the first preview release'
# ReleaseNotes = ''

# Prerelease string of this module
# Prerelease = ''
Expand Down
12 changes: 6 additions & 6 deletions src/MySql/Az.MySql.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@
$accountsName = 'Az.Accounts'
$accountsModule = Get-Module -Name $accountsName
if(-not $accountsModule) {
$localAccountsPath = Join-Path $PSScriptRoot 'generated/modules'
$localAccountsPath = Join-Path $PSScriptRoot 'generated\modules'
if(Test-Path -Path $localAccountsPath) {
$localAccounts = Get-ChildItem -Path $localAccountsPath -Recurse -Include 'Az.Accounts.psd1' | Select-Object -Last 1
if($localAccounts) {
$accountsModule = Import-Module -Name ($localAccounts.FullName) -Scope Global -PassThru
}
}
if(-not $accountsModule) {
$hasAdequateVersion = (Get-Module -Name $accountsName -ListAvailable | Where-Object { $_.Version -ge [System.Version]'1.7.4' } | Measure-Object).Count -gt 0
$hasAdequateVersion = (Get-Module -Name $accountsName -ListAvailable | Where-Object { $_.Version -ge [System.Version]'1.8.1' } | Measure-Object).Count -gt 0
if($hasAdequateVersion) {
$accountsModule = Import-Module -Name $accountsName -MinimumVersion 1.7.4 -Scope Global -PassThru
$accountsModule = Import-Module -Name $accountsName -MinimumVersion 1.8.1 -Scope Global -PassThru
}
}
}

if(-not $accountsModule) {
Write-Error "`nThis module requires $accountsName version 1.7.4 or greater. For installation instructions, please see: https://docs.microsoft.com/en-us/powershell/azure/install-az-ps" -ErrorAction Stop
} elseif (($accountsModule.Version -lt [System.Version]'1.7.4') -and (-not $localAccounts)) {
Write-Error "`nThis module requires $accountsName version 1.7.4 or greater. An earlier version of Az.Accounts is imported in the current PowerShell session. If you are running test, please try to remove '.PSSharedModules' in your home directory. Otherwise please open a new PowerShell session and import this module again.`nAdditionally, this error could indicate that multiple incompatible versions of Azure PowerShell modules are installed on your system. For troubleshooting information, please see: https://aka.ms/azps-version-error" -ErrorAction Stop
Write-Error "`nThis module requires $accountsName version 1.8.1 or greater. For installation instructions, please see: https://docs.microsoft.com/en-us/powershell/azure/install-az-ps" -ErrorAction Stop
} elseif (($accountsModule.Version -lt [System.Version]'1.8.1') -and (-not $localAccounts)) {
Write-Error "`nThis module requires $accountsName version 1.8.1 or greater. An earlier version of Az.Accounts is imported in the current PowerShell session. If you are running test, please try to remove '.PSSharedModules' in your home directory. Otherwise please open a new PowerShell session and import this module again.`nAdditionally, this error could indicate that multiple incompatible versions of Azure PowerShell modules are installed on your system. For troubleshooting information, please see: https://aka.ms/azps-version-error" -ErrorAction Stop
}
Write-Information "Loaded Module '$($accountsModule.Name)'"

Expand Down
7 changes: 7 additions & 0 deletions src/MySql/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
- Additional information about change #1
-->
## Upcoming Release
* Remove legacy SkuSize from input and output (#11725)
* Specify a default name when create MySql firewall rule without name and add AllowAll mode (#11932)
* Enable EndIpAddress to be absent if only one IP to be authorized in firewall rule (#11933)
* Add validateset for parameter StorageAutogrow (#11936)
* Rename New-AzMySqlServerReplica to New-AzMySqlReplica (#11938)
* Use 'master' and 'replica' to avoid confusion when create mysql replica server (#11939)
* Provide hint in doc to use Update-AzMySqlServer & Update-AzMySqlServerConfiguration as a candidate for each other (#11954)

## Version 0.1.0
* the first preview release
Expand Down
4 changes: 2 additions & 2 deletions src/MySql/build-module.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ if(-not $Debugger) {
$null = Remove-Item -Recurse -ErrorAction SilentlyContinue -Path (Join-Path $binFolder 'Debug'), (Join-Path $binFolder 'Release')
}

$dll = Join-Path $PSScriptRoot 'bin/Az.MySql.private.dll'
$dll = Join-Path $PSScriptRoot 'bin\Az.MySql.private.dll'
if(-not (Test-Path $dll)) {
Write-Error "Unable to find output assembly in '$binFolder'."
}
Expand All @@ -97,7 +97,7 @@ if(-not (Test-Path $dll)) {
$null = Import-Module -Name $dll

$modulePaths = $dll
$customPsm1 = Join-Path $PSScriptRoot 'custom/Az.MySql.custom.psm1'
$customPsm1 = Join-Path $PSScriptRoot 'custom\Az.MySql.custom.psm1'
if(Test-Path $customPsm1) {
$modulePaths = @($dll, $customPsm1)
}
Expand Down
12 changes: 7 additions & 5 deletions src/MySql/check-dependencies.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ if(-not $Isolated) {
return
}

function DownloadModule ([bool]$predicate, [string]$path, [string]$moduleName, [string]$versionMinimum) {
function DownloadModule ([bool]$predicate, [string]$path, [string]$moduleName, [string]$versionMinimum, [string]$requiredVersion) {
if($predicate) {
$module = Get-Module -ListAvailable -Name $moduleName
if((-not $module) -or ($versionMinimum -and ($module | ForEach-Object { $_.Version } | Where-Object { $_ -ge [System.Version]$versionMinimum } | Measure-Object).Count -eq 0)) {
$null = New-Item -ItemType Directory -Force -Path $path
Write-Host -ForegroundColor Green "Installing local $moduleName module into '$path'..."
if($versionMinimum) {
if ($requiredVersion) {
Find-Module -Name $moduleName -RequiredVersion $requiredVersion -Repository PSGallery | Save-Module -Path $path
}elseif($versionMinimum) {
Find-Module -Name $moduleName -MinimumVersion $versionMinimum -Repository PSGallery | Save-Module -Path $path
} else {
Find-Module -Name $moduleName -Repository PSGallery | Save-Module -Path $path
Expand All @@ -39,13 +41,13 @@ function DownloadModule ([bool]$predicate, [string]$path, [string]$moduleName, [
$ProgressPreference = 'SilentlyContinue'
$all = (@($Accounts.IsPresent, $Pester.IsPresent) | Select-Object -Unique | Measure-Object).Count -eq 1

$localModulesPath = Join-Path $PSScriptRoot 'generated/modules'
$localModulesPath = Join-Path $PSScriptRoot 'generated\modules'
if(Test-Path -Path $localModulesPath) {
$env:PSModulePath = "$localModulesPath$([IO.Path]::PathSeparator)$env:PSModulePath"
}

DownloadModule -predicate ($all -or $Accounts) -path $localModulesPath -moduleName 'Az.Accounts' -versionMinimum '1.7.4'
DownloadModule -predicate ($all -or $Pester) -path $localModulesPath -moduleName 'Pester' -versionMinimum ''
DownloadModule -predicate ($all -or $Accounts) -path $localModulesPath -moduleName 'Az.Accounts' -versionMinimum '1.8.1'
DownloadModule -predicate ($all -or $Pester) -path $localModulesPath -moduleName 'Pester' -requiredVersion '4.10.1'

$tools = Join-Path $PSScriptRoot 'tools'
$resourceDir = Join-Path $tools 'Resources'
Expand Down
4 changes: 2 additions & 2 deletions src/MySql/custom/Az.MySql.custom.psm1
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# region Generated
# Load the private module dll
$null = Import-Module -PassThru -Name (Join-Path $PSScriptRoot '../bin/Az.MySql.private.dll')
$null = Import-Module -PassThru -Name (Join-Path $PSScriptRoot '..\bin\Az.MySql.private.dll')

# Load the internal module
$internalModulePath = Join-Path $PSScriptRoot '../internal/Az.MySql.internal.psm1'
$internalModulePath = Join-Path $PSScriptRoot '..\internal\Az.MySql.internal.psm1'
if(Test-Path $internalModulePath) {
$null = Import-Module -Name $internalModulePath
}
Expand Down
166 changes: 166 additions & 0 deletions src/MySql/custom/New-AzMySqlFirewallRule.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@

# ----------------------------------------------------------------------------------
#
# 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
Creates a new firewall rule or updates an existing firewall rule.
.Description
Creates a new firewall rule or updates an existing firewall rule.
#>
function New-AzMySqlFirewallRule {
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.MySql.Models.Api20171201.IFirewallRule])]
[CmdletBinding(DefaultParameterSetName='CreateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
param(
[Parameter()]
[Alias('FirewallRuleName')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Path')]
[System.String]
# The name of the server firewall rule.
# If not specified, the default is undefined.
# If AllowAll is present, the default name is AllowAll_yyyy-MM-dd_HH-mm-ss.
${Name},

[Parameter(Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Path')]
[System.String]
# The name of the resource group.
# The name is case insensitive.
${ResourceGroupName},

[Parameter(Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Path')]
[System.String]
# The name of the server.
${ServerName},

[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(ParameterSetName='CreateExpanded')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')]
[System.String]
# The end IP address of the server firewall rule.
# Must be IPv4 format.
${EndIPAddress},

[Parameter(ParameterSetName='CreateExpanded', Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')]
[System.String]
# The start IP address of the server firewall rule.
# Must be IPv4 format.
# If range contains one IP, use StartIPAddress only.
${StartIPAddress},

[Parameter(ParameterSetName='AllowAll', Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')]
[System.Management.Automation.SwitchParameter]
# Present to allow all range IPs, from 0.0.0.0 to 255.255.255.255.
${AllowAll},

[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()]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
# Run the command as a job
${AsJob},

[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()]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
# Run the command asynchronously
${NoWait},

[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 {
if($PSBoundParameters.ContainsKey('AllowAll'))
{
if(!$PSBoundParameters.ContainsKey('Name'))
{
$PSBoundParameters['Name'] = Get-Date -Format "AllowAll_yyyy-MM-dd_HH-mm-ss"
}
$PSBoundParameters['StartIPAddress'] = "0.0.0.0"
$PSBoundParameters['EndIPAddress'] = "255.255.255.255"

$null = $PSBoundParameters.Remove('AllowAll')
}
else
{
if(!$PSBoundParameters.ContainsKey('Name'))
{
$PSBoundParameters['Name'] = "undefined"
}
if(!$PSBoundParameters.ContainsKey('EndIPAddress'))
{
$PSBoundParameters['EndIPAddress'] = $PSBoundParameters['StartIPAddress']
}
}

Az.MySql.internal\New-AzMySqlFirewallRule @PSBoundParameters
} catch {
throw
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
# limitations under the License.
# ----------------------------------------------------------------------------------

function New-AzMySqlServerReplica {
function New-AzMySqlReplica {
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.MySql.Models.Api20171201.IServer])]
[CmdletBinding(DefaultParameterSetName='CreateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Description('Creates a new replica from an existing database.')]
param(
[Parameter(Mandatory, HelpMessage = 'The name of the server.')]
[Alias('ReplicaServerName')]
[Alias('ReplicaServerName', 'Name')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Path')]
[System.String]
${Name},
${Replica},

[Parameter(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')]
Expand All @@ -36,9 +36,10 @@ function New-AzMySqlServerReplica {
${SubscriptionId},

[Parameter(Mandatory, ValueFromPipeline, HelpMessage = 'The source server object to create replica from.')]
[Alias('InputObject')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Models.Api20171201.IServer]
${InputObject},
${Master},

[Parameter(HelpMessage = 'The location the resource resides in.')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')]
Expand Down Expand Up @@ -112,10 +113,10 @@ function New-AzMySqlServerReplica {
$Parameter.Property = [Microsoft.Azure.PowerShell.Cmdlets.MySql.Models.Api20171201.ServerPropertiesForReplica]::new()
$Parameter.CreateMode = [Microsoft.Azure.PowerShell.Cmdlets.MySql.Support.CreateMode]::Replica

$server = $PSBoundParameters['InputObject']
$server = $PSBoundParameters['Master']
$Parameter.Property.SourceServerId = $server.Id
$Parameter.Location = $server.Location
$null = $PSBoundParameters.Remove('InputObject')
$null = $PSBoundParameters.Remove('Master')

if ($PSBoundParameters.ContainsKey('Location')) {
$Parameter.Location = $PSBoundParameters['Location']
Expand All @@ -127,6 +128,12 @@ function New-AzMySqlServerReplica {
$null = $PSBoundParameters.Remove('Sku')
}

if ($PSBoundParameters.ContainsKey('Replica'))
{
$PSBoundParameters['Name'] = $PSBoundParameters['Replica']
$null = $PSBoundParameters.Remove('Replica')
}

$PSBoundParameters.Add('Parameter', $Parameter)

Az.MySql.internal\New-AzMySqlServer @PSBoundParameters
Expand Down
1 change: 1 addition & 0 deletions src/MySql/custom/New-AzMySqlServer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ function New-AzMySqlServer {

[Parameter(HelpMessage = 'Enable Storage Auto Grow.')]
[ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.MySql.Support.StorageAutogrow])]
[Validateset('Enabled', 'Disabled')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Category('Body')]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.Support.StorageAutogrow]
${StorageAutogrow},
Expand Down
Loading