I am experimenting with XData server running on Azure hosted machine. This is connected to a MSSQL database also in Azure.
I have this running and have exposed some data which I can GET from a simple Web Client running default on localhost:8000.
I want to host my WebApp on Azure and sftp the required files to site/wwwroot everything runs fine UNTIL I try to connect the WebApp to the XData service where it fails to connect with this:
ERROR
XDataConnectionError: Error connecting to XData server | fMessage::XDataConnectionError: Error connecting to XData server FJSError::Error: XDataConnectionError: Error connecting to XData server fHelpContext::0
at https://imlweb.azurewebsites.net/webProject.js [79489:13]
Hi Steven
Make sure that you added CORS middleware to your XDataServer's middleware list. If not this may be a reason. Right mouse click XDataServer, select manage middleware list and add middleware, select CORS. If this is the case of your problem have a look at this url for docs. https://doc.tmssoftware.com/biz/sparkle/guide/middleware.html#cors-middleware
The CORS side I had addressed after reading the documentation and Holger Flicks "TMS Web Core" and "Hands-On with Delphi".
I have kept my experiments as close to the guide as possible.
Ok - so I have found my error.
If I make the request using HTTP it works, if I use HTTPS I get the error, looks like I need to brush up on my web skills around mixed content:
Yes, that's how browsers work, If the page is accessed via HTTPS, then all the requests it mades (including to XData server) must also be done using HTTPS.
For the life of me I CANNOT get HTTPS to work for me. I have secured my azure XData client, assigned custom domain name and added SSL.
However, I just can't get the SSL bindings to work on the VM that hosts the XDataServer. I am aware that this is probably outside the scope of TMS support but I have so many apps that are still using a direct connection to SQL server and I have struggled with this for a couple of years I am hoping another customer has the resolution, I know I am close.....
If I leave everything as HTTP it works so I know my connections work.
Last piece is adding the SSL to the public IP on the Azure VM, this has no DNS entry, I can then amend the app components to look at https.
HOPEFULLY someone has cracked this.
I have now used a domain name for the IP address and obtained a GoDaddy SSL which I have installed on the VM. When I try to add the SSL certificate through the Config Tool I get the following error:
Having looked at all of this I finally managed to get the setup to work by deleting all certificate entries and rekeying my GoDaddy certificate with a CSR generated through the certlm MMC snap-in. For future reference, both mine and any other users, here are the basic steps to generate and install a working SSL certificate on an Azure VM with public IP:
Assign a domain name to the public IP
In MMC navigate to Certificates - Local Computer\Personal\Certificates
Right click select AllTasks/Advanced Operations/Create Custom request > Next
Select Custom Request\Proceed without enrollment policy > Next
Select (No Template) CNG key and PKS#10 > Next
Select Details/Properties
Add a friendly name (I used domain name) and description
Select Subject Tab and add Subject Name/Common Name value=domain.com > Add>
Select Private Key Tab/Key Options/ Key Size=2048 and tick Make Private Key exportable
>OK >Next Give the file a name and Save > Finish
Open the generated CSR file in Notepad and use this to generate your SSL in GoDaddy. The only entry I put in the certificate was the domain name I had assigned to the Public IP address.
Download the ZIP file and copy the 3 files to the machine to be secured
Install the 2 *.crt files in Local Computer/Personal
Make sure https://+:port/root has been added to HTTPConfig and on the SSL tab select the newly installed certificate on ip 0.0.0.0