Blog Post

Healthcare and Life Sciences Blog
3 MIN READ

Deploying OpenEMR on Azure

DavidMGinn's avatar
DavidMGinn
Icon for Microsoft rankMicrosoft
Feb 13, 2023

Open EMR Deployment

 

Below is a detailed guide to installing OpenEMR Leveraging Azure Web Apps + Database. This walkthrough will guide you in:

  • Creating the Web App + Database
  • Downloading the OpenEMR Source Code
  • Deploying the Source to your Azure Web App
  • Running the database installScript from a command prompt
  • Video Demonstration - https://youtu.be/rhRzC28nI7g

Not an Azure customer yet? Click here to sign up and get $200 in free Azure credit.

 

  1. Browse to the Azure Portal and select “Create a Resource”

 

  1. Search for and select “Web App + Database
”

 

  1. Click “Create”

 

  1. Complete the form (UPDATE- we are now using PHP 8.2 and OpenEMR 7.0.2) and click “Review and Create”

 

  1. Review Settings - be sure to capture username / password for your database for later use, and then click “Create”

 

  1. Wait for deployment to complete and click “Go to resource”

 

  1. Download openemr-7.0.2.zip from here: OpenEMR 7.0.2 Windows Installation
  2. Extract and open the extracted folder within Visual Studio Code
  3. Ensure that the Azure App Service Extension is installed in Visual Studio Code

 

  1. In the Azure Portal, browse to the resource group that was chosen as part of your deployment and find the “Azure Database for MySQL flexible server” resource


  2. *UPDATE* - Select the "Server parameters" blade, choose "All" and search for "sql_generate_invisible_primary_key". Set its value to "OFF". Click the Save button.


  3. Select the “Networking” blade under the “Settings” section, and click “Download SSL Certificate”


  4. Open Visual Studio Code and copy the downloaded certificate into the “/sites/default/documents/certificates” folder and rename it to “mysql-ca” with no file extension


  5. Within Visual Studio Code, navigate to “/contrib/util/installScripts/InstallerAuto.php “ and comment out the “exit;” statement on line 78, then save the file


  6. Select the Azure icon in Visual Studio Code. You may need to sign-in at this stage. Once you’ve signed in, expand the Azure Subscription and App Services and look for the App Service you created in Step 5.


  7. Right click on the desired App Service, and click “Deploy to Web App”


  8. Select the source folder you wish to deploy. By default this will be the current folder open in Visual Studio Code


  9. Click “Deploy”



  10. Open the output window to view the progress. This may take some time



  11. Upon successful completion, browse back to the selected Resource Group, and select your App Service


  12. Select “SSH” Under “Development Tools”, and click “Go ->”


  13. Navigate to the installScripts folder using the command “cd site/wwwroot/contrib/util/installScripts"


  14. Execute the command “php -f InstallerAuto.php server=<server-name> loginhost=% root=<username> rootpass=<password> login=<openemr-db-user> pass=<openemr-db-pass>” using the username noted in step 5 for “root” and password noted in step 5 for "rootpass" and a username and password of your choosing for “openemr-db-user “openemr-db-pass”. You may optionally include any of the parameters located on lines 84-102 of “installerAuto.php” if you wish to change any settings from their defaults. For a production installation, it is recommended to change any username and password settings from their default value.

    You can obtain the server name by browsing to your resource group and clicking the Azure Database for MySQL flexible server resource and copying the “Server name” property





  15. Execute the above command, it will take some time to complete.

Once this command completes and returns to the command prompt, you may close the SSH browser tab to return back to your Azure Web App

  16. Select the “Overview” blade and click the “URL” to browse to your site.


  17. If your install was successful, you will see the OpenEMR Login Screen. By default, the username is “admin” and password is “pass” unless these were changed when running the install command from step 23.



  18. Congratulations! You have successfully installed OpenEMR on Azure!

Walkthrough Video Demonstration

 

 

Updated Jan 23, 2024
Version 9.0
  • markrothfield's avatar
    markrothfield
    Copper Contributor

    Thanks for the guide, really easy to follow and worked great. I did find a small issue at step 22 where the command returned the following error:

     

    PHP Fatal error: Uncaught mysqli_sql_exception: Failed to generate invisible primary key. Auto-increment column already exists. in /home/site/wwwroot/library/classes/Installer.class.php:1288
    Stack trace:
    #0 /home/site/wwwroot/library/classes/Installer.class.php(1288): mysqli_query(Object(mysqli), 'CREATE TABLE `a...')
    #1 /home/site/wwwroot/library/classes/Installer.class.php(325): Installer->execute_sql('CREATE TABLE `a...')
    #2 /home/site/wwwroot/library/classes/Installer.class.php(273): Installer->load_file('/home/site/wwwr...', 'Main')
    #3 /home/site/wwwroot/library/classes/Installer.class.php(1217): Installer->load_dumpfiles()
    #4 /home/site/wwwroot/contrib/util/installScripts/InstallerAuto.php(127): Installer->quick_install()
    #5 {main}
    thrown in /home/site/wwwroot/library/classes/Installer.class.php on line 1288

     

    The resolution was as follows:

     

    1) Login to Azure Database for MySQL flexible server, click on Databases blade and delete the openemr database which has just been created.

    2) Click on the Server Parameters blade, select the All filter, search for sql_generate_invisible_primary_key and set to NO. Press Save

    3) Go back to the command prompt and rerun the command from step 22.

  • raseniero RandyJ62 I'm looking why the link to download the SSL certificate is no longer available and what the alternative would be, thank you for pointing this out.

    Edit: It appears the download option has been moved under the Networking blade, as seen in this screen shot.

     

  • MattCosturos's avatar
    MattCosturos
    Copper Contributor

    I'm running into a vague `ERROR: unable to connect to database as root`

     

    I am doing

     

     

    php -f InstallerAuto.php servier=my-server-name.mysql.datgabase.azure.com loginhost=% root=myRootUsername rootpass=myRootPassword login=myAdmin pass=myAdminPass`

     

     

     

    I did include the public key cert i downloaded from the cert at the location `/sites/default/documents/certificates/mysql-ca` before deploying the app to the app service.

     

    Any way I can enable more logging to find out the source of the connection error?

    What folder can I go look in to verify the public key cert is in the correct spot?

     

    EDIT:

    The problem was a `$` in the root password. It seems to break the install script. Something I've run into with bash scripts in the past

  • raseniero's avatar
    raseniero
    Copper Contributor

    DavidMGinn I've followed the steps but when I get to the steps for downloading the MySQL Cert -- the link does not shows up. do you have other alternative to generate the Cert?

  • jonjof210's avatar
    jonjof210
    Copper Contributor

    If I already  have an established installation of OpenEMR on a lcoal server with the same versions of php and OpenEMR, should it work if I install the application on Azure, and then replace all my established data folders from my current installation?. If this is a option, can you guide me on such a process. e.g. can services on the Azure app be stopped etc in order to overwrite active files?

    Thanks   

  • jonjof210 I have not tried that. But in theory it should work. You can pause or stop the App Service while updating the files.

  • Hi

     

    I also experiencing this error

    "Unable to connect to database as root"

     

    I have followed the steps but am not sure where I went wrong

     

    Kindly advise

     

    Regards

  • Mr_More's avatar
    Mr_More
    Copper Contributor

    I having having the same error. Even after downloading the certificates and also modifying the server parameter to disable SSL, 

     PHP Warning: mysqli_real_connect(): SSL operation failed with code 1. OpenSSL Error messages:
    error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed in /home/site/wwwroot/openemr-7.0.2/library/classes/Installer.class.php on line 1396
    ERROR: unable to connect to database as root
    root@cloudemr_a85009df4e:/home/site/wwwroot/openemr-7.0.2/contrib/util/installScripts#