/azure-mysql

Primary LanguagePowerShellMIT LicenseMIT

azure-mysql

Prerequisites

Getting Started

  • Clone or download this repo.
  • Navigate to the folder containing the local version of this repo in PowerShell
  • Create target resource group using Azure Portal, Az PowerShell or Azure CLI.
  • Update parameter file as required Default provided in parameters file - see Parameters section for details.
  • Run the interactive deployment script: (this will securely prompt for administrator password)
$ .\deploy\interactive.ps1 -ResourceGroupName 'test-mysql-resource-group'

Enter admin password: **********

DeploymentName          : template
ResourceGroupName       : test-client-mysql-resource-group
ProvisioningState       : Succeeded
Timestamp               : 19/01/2021 14:54:57
Mode                    : Incremental
TemplateLink            :
Parameters              :
                          Name                          Type                       Value
                          ============================  =========================  ==========
                          administratorLogin            String                     gracehopper
                          administratorLoginPassword    SecureString
                          location                      String                     uksouth
                          serverName                    String                     test-server-name
                          skuCapacity                   Int                        2
                          skuFamily                     String                     Gen5
                          skuName                       String                     B_Gen5_2
                          skuSizeMB                     Int                        51200
                          skuTier                       String                     Basic
                          version                       String                     5.7
                          backupRetentionDays           Int                        7
                          geoRedundantBackup            String                     Disabled
                          previewFeature                String
                          tags                          Object                     {}
                          storageAutoGrow               String                     Enabled
                          infrastructureEncryption      String                     Disabled
                          firewallRules                 Array                      []
Outputs                 :
DeploymentDebugLogLevel :

Parameters

Most of the parameters below match closely with their equivalents for the related resource templates in which they are used, all of which are documented on https://docs.microsoft.com/en-us/azure/templates/.

administratorLogin

A non-null value must be provided - see ServerPropertiesForDefaultCreate object for usage. For automated deployments this value is best set from a value stored in an existing Key Vault.

  "parameters": {
       
        "administratorLogin": {
            "value": null
        },
       
  }

administratorLoginPassword

You can supply non-null value here, but it is strongly recommended that you do not. For interactive deployments it is preferable to use the ability of the New-AzResourceGroupDeployment cmdlet to provide values for template parameters - see provided deployment script for an example of this. For automated deployments this value is best set from a value stored in an existing Key Vault.

  "parameters": {
      
        "administratorLoginPassword": {
            "value": null
        },
      
  }

serverName

A non-null value must be provided - see Microsoft.DBforMySQL/servers object for usage.

  "parameters": {

        "serverName": {
            "value": "my-mysql-server"
        },

  }

location

Default provided in parameters file - see Microsoft.DBforMySQL/servers object for usage.

  "parameters": {

        "location": {
            "value": "uksouth"
        },

  }

skuName

Default provided in parameters file - see SKU object for usage.

  "parameters": {

        "skuName": {
            "value": "B_Gen5_2"
        },

  }

skuTier

Default provided in parameters file - see SKU object for usage.

  "parameters": {

        "skuTier": {
            "value": "Basic"
        },

  }

skuCapacity

Default provided in parameters file - see SKU object for usage.

  "parameters": {

        "skuCapacity": {
            "value": 2
                },

  }

skuFamily

Default provided in parameters file - see SKU object for usage.

  "parameters": {

        "skuFamily": {
            "value": "Gen5"
                },

  }

skuSizeMB

Default provided in parameters file - see SKU object for usage.

  "parameters": {

        "skuSizeMB": {
            "value": 51200
                },

  }

backupRetentionDays

Default provided in parameters file - see StorageProfile object for usage.

  "parameters": {

        "backupRetentionDays": {
            "value": 7
                },

  }

geoRedundantBackup

Default provided in parameters file - see StorageProfile object for usage.

  "parameters": {

        "geoRedundantBackup": {
            "value": "Disabled"
                },

  }

storageAutoGrow

Default provided in parameters file - see StorageProfile object for usage.

  "parameters": {

        "storageAutoGrow": {
            "value": "Enabled"
        },

  }

tags

Default provided in parameters file - see Microsoft.DBforMySQL/servers object for usage.

  "parameters": {

        "tags": {
            "value": {}
        },
       
  }

infrastructureEncryption

Default provided in parameters file - see ServerPropertiesForCreate object for usage.

  "parameters": {
 
        "infrastructureEncryption": {
            "value": "Disabled"
                },

  }

version

Default provided in parameters file - see ServerPropertiesForCreate object for usage.

  "parameters": {

        "version": {
            "value": "5.7"
                },

  }

firewallRules

For each firewall rule add an object with these properties to the value array of this parameter.

{
    "name": "<fw-rule-name>",
    "startIpAddress": "<valid-ipv4-address>",
    "endIpAddress": "<valid-ipv4-address>"
}

See Microsoft.DBforMySQL servers/firewallRules for details of these properties.

Example:

  "parameters": {

        "firewallRules": {
            "value": [               
                {
                    "name": "Office",
                    "startIpAddress": "127.0.0.1",
                    "endIpAddress": "127.0.0.1"
                }
            ]
        }
        
    }

Note: the invalid value 127.0.0.1 (for a public IP address)is used above deliberately in order to prevent accidentally opening a hole in the firewall from copy & pasting this example.

Allow all Azure IPs

To allow access from any Azure IP you can set both startIpAddress and endIpAddress to "0.0.0.0" as shown below.

Note: this is not recommended for most scenarios and should only be used where no other option exists and you fully appreciate the security impact of this decision.

  "parameters": {

        "firewallRules": {
            "value": [               
                {
                    "name": "AllowAllAzureIPs",
                    "startIpAddress": "0.0.0.0",
                    "endIpAddress": "0.0.0.0"
                }
            ]
        }
    }