mysqlazureazure-database-mysql

Add another user in Microsoft Azure Database for Mysql Server


I am using Microsoft Azure database for Mysql server in my mysql workbench. Now I have dynamic IP set so every time when changing the place I have to open the Azure and enter my IP manually.

Now I want to give access to a friend but I don't want to go through the pain stacking processing of adding IP address and also I don't want to give him my user ID and password to the friend.

So is there any way to give access to my friend to the mysql server?

Thank you in adance.


Solution

  • I don't want to give him my user ID and password to the friend.

    You could create a new user as you normally do, and grant proper privileges to it.

    so every time when changing the place I have to open the Azure and enter my IP manually.

    I have a script for you, but not for your friend. Unless you are willing to let him access your subscription.

    This script requires you have Azure CLI installed/configured(since there is no powershell cmdlet for Azure database for MySQL) and it's a powershell script:

    $ip = Invoke-RestMethod http://ipinfo.io/json | Select -exp ip
    
    $command = @'
    cmd.exe /C az mysql server firewall-rule update --resource-group RESOURCEGROUPNAME --
    server SERVERNAME --name "FIREWALLRULENAME" --start-ip-address $ip --end-ip-
    address $ip
    '@
    
    Invoke-Expression -Command:$command