Sorry, this entry is only available in Italian.
In the Overview section of the your Azure web application, select “Get publish profile”. It will download a file that has a lot of things and the details about FTP username and password, which is constant and can be used for FTP connection.
You have a WordPress site hosted on Microsoft Azure.Perhaps your site is part of a free or shared app service plan.
Trying to connect to the site, one day, you have this wordpress error message: Error establishing a database connection
How to find out and solve the problem?
Connecting to Microsoft Azure Service with FTP
First of all you have to connect to the site via ftp to understand where the error is. We can connect to Azure web application with FTP also. In the Overview section of the your Azure web application, select “Get publish profile”. It will download a file that has a lot of things and teh details about FTP username and password, which is constant and can be used for FTP connection.
Enable WordPress Debug Logging
You need FTP connection to enable WordPress Debug Logging. To enable error logging in WordPress, you will have to make both of the following changes :
- In wwwroot directory, create a file named .user.ini Add the following line:
- In wwwroot directory, open wp-config.php
Add the following lines :
//Enable WP_DEBUG mode
//Enable Debug Logging to /wp-content/debug.log
//Supress errors and warnings to screen
//Supress PHP errors to screen
Also comment the line :
/* define('WP_DEBUG', false); */
Analyze the Log File
Try to load your site. Now, through ftp, you can enter in the directoy LogFiles and analyze the file
Perhaps you have a database error, for example a duplicate key problem. On azure, in your app service, select Mysql In -app button. On the top of the section, you can see the Manage button. Click on the button and you’ll load the phpMyAdmin portal on your local Mysql DB.
If you have this kind of error : Duplicate entry ‘XXXXX’ for key ‘PRIMARY’ for the query INSERT INTO `table_name`, just ran following command :
That’s it! It was done.
This is the procedure we followed to register a new Microsoft Azure subscription for a company that does not have a subscription to Office 365.
Visit https://account.windowsazure.com/organization to sign up for Azure with a new organization.
Enter the name and surname of the company reference.
A name for the company domain similar to xxxxx.onmicrosoft.com.
Use your email address for reference.
Enter an username, for example admin and password; company
Enter company’s vat registration number.
As part of the process of signing up for Azure, you will be required to provide credit card details. We didn’t insert it. Whenever you log in to Azure’s portal you are asked for your credit card details.
You have to bought a new Azure Subscription Services Open from the Microsoft distributor, using Company’s name, your mail address (the same used creating Azure account) and Company’s vat registration number.
Using Microsoft Edge, enter, in Azure Portal : credit card details are no longer required. You can add the license of the new Azure Subscription Services Open. That’s all.
|Windows 8||64 bit||Enterprise, Pro|
|Windows 7||64 bit||Ultimate, Enterprise, Professional, Home Premium, Home Basic, Starter|
|Windows 8.1||64 bit||Enterprise, Pro|
|Windows 10||64 bit||Enterprise, Pro, Home|
|Windows Server 2016||64 bit||Standard, Datacenter, Essentials|
|Windows Server 2012 R2||64 bit||Standard, Datacenter, Foundation, Essential|
|Windows Server 2012||64 bit||Datacenter, Foundation, Standard|
|Windows Storage Server 2016||64 bit||Standard, Workgroup|
|Windows Storage Server 2012 R2||64 bit||Standard, Workgroup|
|Windows Storage Server 2012||64 bit||Standard, Workgroup|
|Windows Server 2008 R2 SP1,||64 bit||Standard, Enterprise, Datacenter, Foundation|
|Windows Server 2008 SP2||64 bit||Standard, Enterprise, Datacenter, Foundation|
Join Azure through the old portal
In the left menu, move to SETTINGS
Select the ADMINISTRATOR label
At the bottom, push the “Add” button. Follow the instructions.
Visual Studio allows us to publish our web site on a web server in the lan (intranet) or on an external web server, for example hosted on Azure.
In the situation of a server on the lan, you have created, through IIS, a site that resides on a certain directory, empty now, on a web server. Otherwise you have already prepared an external site.
In Visual Studio, in the right panel called “Solution Explorer” we click with the right mouse button on our project and select the “Publish” option. The “Publish” window: there are, on the left, the fourth step to do for publication.
Go to the drop down menu at the top center and choose “New Custom Profile”. Invent the name of this profile. Once inserted, you will go directly to the next step.
Connection with “Web Deploy”
Publish Metod : choose “Web Deploy” whether you publish your site on a server on the lan, both in an external server.
Server (web server in lan) : http://myserver
Server (external, es Azure): mysite.azurewebsites.net:443
Site name (web server in lan) : name of the directory in which it is to be the site
Site name (external, es Azure) : es. mysite
User Name e Password (web server in lan) : put a administrator user of the server machine. If the machine is in a domain, use a local administrator.
User Name e Password (esterno) : ftp user
Destination Url : web site address. es : http://……………..
In this tab the program reads from we.config the database connection strings. If your target site database is different, you need to specify the right connection. The publication will replace the target strings to the source strings. We will see later that there is a method to insert in the web.config further changes to the web.config of origin.
Here you can see the files that will be sent to the destination that is the new files or changed since the last submission. And you can publish your site!
Our destination website may have other special features, specified in web.config, different from the starting site, as well as database connection strings. We can create a specific web.config for each deployment.
Position the mouse on the project. In the “Properties”, find the directory “PublishProfiles” which contains previously saved data. Here you will find a .pubxml files for each of the deployment that you have created. Go to the file you need, push the right mouse button and select “Add Config Transform”.
If you go in the web.config you will see that there is an additional file named as your deployment. Let’s see some examples of what you can do with the tag that you set within the <configuration>
<connectionStrings> <add name="MyDB" connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/> </connectionStrings>
this stringa substitutes (xdt:Transform=”SetAttributes”) the attributes of the tag named (xdt:Locator=”Match(name)) “MyDB” with these.
<appSettings><add key="myemail" value="email@example.com" xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/></appSettings>
this stringa substitutes the attributes (xdt:Transform=”SetAttributes”) of the tag with key (xdt:Locator=”Match(key)) “myemai” with these.
<system.net> <mailSettings xdt:Transform="Replace"> <smtp deliveryMethod="Network" ........................ </smtp> </mailSettings> </system.net>
This string transform (xdt:Transform=”Replace”) entire tag mailSettings and its content.