<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Hi again,</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Reviewing the source for the parsing function it looks like it won't be possible.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"><a href="https://github.com/kamailio/kamailio/blob/5295a4f5eac08c1bb100bf554a995833c434c4dc/src/modules/db_mysql/my_uri.c#L147" class="OWAAutoLink" id="LPlnk526631" previewremoved="true">https://github.com/kamailio/kamailio/blob/5295a4f5eac08c1bb100bf554a995833c434c4dc/src/modules/db_mysql/my_uri.c#L147</a></p>
<br>
We see that once it hits the @, if it hasn't hit a : or / before it will assume everything to the left of the @ is the username and then it will start to parse everything to the right of the @ as the hostname.
<div><br>
</div>
<div>In your case the host will be: clouddb and the port will be: <span>password@clouddb.mysql.database.azure.com</span></div>
<div><span><br>
</span></div>
<div><span>Have you checked the docs under section 6?: 
<pre style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 15px; margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; color: rgb(36, 41, 46);">6. Reading configuration from my.cnf</pre>
<pre style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 15px; margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; color: rgb(36, 41, 46);"><br></pre>
<pre style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 15px; margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; color: rgb(36, 41, 46);">Not sure how that is implemented to fetch the data but that might perhaps be a way to get around the parsing structure in the mysql module.</pre>
<pre style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 15px; margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; color: rgb(36, 41, 46);"><br></pre>
<pre style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 15px; margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; color: rgb(36, 41, 46);">Also, feel free to submit a patch for the above parsing function if possible.</pre>
</span></div>
<div><br>
<p></p>
<p style="margin-top:0;margin-bottom:0">// Samuel</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
</div>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> sr-users <sr-users-bounces@lists.kamailio.org> on behalf of Floimair Florian <f.floimair@commend.com><br>
<b>Sent:</b> Monday, November 27, 2017 4:47:52 PM<br>
<b>To:</b> Kamailio (SER) - Users Mailing List<br>
<b>Subject:</b> Re: [SR-Users] URL problems connecting to external (Azure) MySQL database</font>
<div> </div>
</div>
<style>
<!--
@font-face
        {font-family:"Cambria Math"}
@font-face
        {font-family:Calibri}
@font-face
        {font-family:Hack}
p.x_MsoNormal, li.x_MsoNormal, div.x_MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif}
a:x_link, span.x_MsoHyperlink
        {color:#0563C1;
        text-decoration:underline}
a:x_visited, span.x_MsoHyperlinkFollowed
        {color:#954F72;
        text-decoration:underline}
p.x_msonormal0, li.x_msonormal0, div.x_msonormal0
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif}
p.x_xmsonormal, li.x_xmsonormal, div.x_xmsonormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif}
p.x_xmsochpdefault, li.x_xmsochpdefault, div.x_xmsochpdefault
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif}
span.x_xe-mailformatvorlage17
        {font-family:"Calibri",sans-serif;
        color:windowtext}
span.x_E-MailFormatvorlage23
        {font-family:"Calibri",sans-serif;
        color:windowtext}
.x_MsoChpDefault
        {font-size:10.0pt}
@page WordSection1
        {margin:70.85pt 70.85pt 2.0cm 70.85pt}
div.x_WordSection1
        {}
-->
</style>
<div lang="DE" link="#0563C1" vlink="#954F72">
<div class="x_WordSection1">
<p class="x_MsoNormal"><span lang="EN-US" style="">Thanks for your quick reply!</span></p>
<p class="x_MsoNormal"><span lang="EN-US" style=""> </span></p>
<p class="x_MsoNormal"><span lang="EN-US" style="">Unfortunately the result is exactly the same error.</span></p>
<p class="x_MsoNormal"><span lang="EN-US" style=""> </span></p>
<div>
<p class="x_MsoNormal" style=""><span lang="EN-US" style="font-size:12.0pt; font-family:"Times New Roman",serif"> </span></p>
<p class="x_MsoNormal" style=""><span lang="EN-US" style="font-size:12.0pt; font-family:"Times New Roman",serif"> </span></p>
<p class="x_MsoNormal"><span lang="EN-US" style="font-size:10.0pt; font-family:"Arial",sans-serif; color:black">With best regards</span></p>
<p class="x_MsoNormal"><span lang="EN-US" style="font-size:10.0pt; font-family:"Arial",sans-serif; color:black"><br>
</span><b><span lang="EN-US" style="font-size:10.0pt; font-family:"Arial",sans-serif; color:black">Florian Floimair<br>
<br>
</span></b><span lang="EN-US" style="font-size:12.0pt; font-family:"Times New Roman",serif"></span></p>
</div>
<p class="x_MsoNormal"><span lang="EN-US" style=""> </span></p>
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0cm 0cm 0cm">
<p class="x_MsoNormal"><b>Von:</b> sr-users [mailto:sr-users-bounces@lists.kamailio.org]
<b>Im Auftrag von </b>Samuel F.<br>
<b>Gesendet:</b> Montag, 27. November 2017 16:04<br>
<b>An:</b> Kamailio (SER) - Users Mailing List <sr-users@lists.kamailio.org><br>
<b>Betreff:</b> Re: [SR-Users] URL problems connecting to external (Azure) MySQL database</p>
</div>
</div>
<p class="x_MsoNormal"> </p>
<div id="x_divtagdefaultwrapper">
<p><span style="font-size:12.0pt; color:black">Hey,</span></p>
<p><span style="font-size:12.0pt; color:black"> </span></p>
<p><span style="font-size:12.0pt; color:black">Could you try replacing the @-sign in the username with: %40  (percent-forty)?</span></p>
<p><span style="font-size:12.0pt; color:black"> </span></p>
<p><span style="font-size:12.0pt; color:black">// Samuel</span></p>
</div>
<div class="x_MsoNormal" align="center" style="text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="x_divRplyFwdMsg">
<p class="x_MsoNormal"><b><span style="color:black">From:</span></b><span style="color:black"> sr-users <<a href="mailto:sr-users-bounces@lists.kamailio.org">sr-users-bounces@lists.kamailio.org</a>> on behalf of Floimair Florian <<a href="mailto:f.floimair@commend.com">f.floimair@commend.com</a>><br>
<b>Sent:</b> Monday, November 27, 2017 3:33:21 PM<br>
<b>To:</b> Kamailio (SER) - Users Mailing List<br>
<b>Subject:</b> [SR-Users] URL problems connecting to external (Azure) MySQL database</span>
</p>
<div>
<p class="x_MsoNormal"> </p>
</div>
</div>
<div>
<div>
<p class="x_xmsonormal">Hi!</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal"><span lang="EN-US">I’m having troubles connecting Kamailio to an external MySQL database (on Microsoft Azure Cloud).</span></p>
<p class="x_xmsonormal"><span lang="EN-US">Initially creating the database with kamctl worked fine, but accessing it at runtime via db_url fails.</span></p>
<p class="x_xmsonormal"><span lang="EN-US"> </span></p>
<p class="x_xmsonormal"><span lang="EN-US">A somewhat unusual thing about the connection to a MySQL database on Azure is that the username contains an ‘@’ character.</span></p>
<p class="x_xmsonormal"><span lang="EN-US">This leads me to believe that this case is somewhat unhandled when parsing the database URI.</span></p>
<p class="x_xmsonormal"><span lang="EN-US"> </span></p>
<p class="x_xmsonormal"><span lang="EN-US">Trying to connect to something like</span></p>
<p class="x_xmsonormal"><span lang="EN-US"> </span></p>
<p class="x_xmsonormal"><span lang="EN-US" style="font-size:10.0pt; font-family:Hack">modparam("sipcapture", "db_url", "mysql://user@clouddb:password@clouddb.mysql.database.azure.com/db")</span></p>
<p class="x_xmsonormal"><span lang="EN-US"> </span></p>
<p class="x_xmsonormal"><span lang="EN-US">Results in errors starting Kamailio</span></p>
<p class="x_xmsonormal"><span lang="EN-US"> </span></p>
<p class="x_xmsonormal" style="text-autospace:none"><span lang="EN-US" style="font-size:10.0pt; font-family:Hack; color:#CB4B16">ERROR: db_mysql [km_my_con.c:124]: db_mysql_new_connection(): driver error: Unknown MySQL server host 'clouddb' (-2)</span></p>
<p class="x_xmsonormal" style="text-autospace:none"><span lang="EN-US" style="font-size:10.0pt; font-family:Hack; color:#CB4B16">ERROR: <core> [db.c:318]: db_do_init2(): could not add connection to the pool</span></p>
<p class="x_xmsonormal"><span lang="EN-US" style="font-size:10.0pt; font-family:Hack; color:#CB4B16">ERROR: sipcapture [sipcapture.c:1146]: child_init(): unable to connect to database [<a href="">mysql://user@clouddb:password@clouddb.mysql.database.azure.com/db</a>]
 from capture_mode param.</span></p>
<p class="x_xmsonormal"><span lang="EN-US" style="color:black">Is there a trick on how to achieve a connection in this case like some sort of escape character probably?</span></p>
<p class="x_xmsonormal"><span lang="EN-US" style="font-size:10.0pt; font-family:"Arial",sans-serif; color:black"> </span></p>
<p class="x_xmsonormal"><span lang="EN-US" style="font-size:10.0pt; font-family:"Arial",sans-serif; color:black"> </span></p>
<p class="x_xmsonormal"><span lang="DE-AT" style="font-size:10.0pt; font-family:"Arial",sans-serif; color:black">Mit freundlichen Grüßen<br>
<br>
<b>Florian Floimair (IMS) 1568</b></span></p>
<p class="x_xmsonormal"><span lang="DE-AT" style="font-size:12.0pt; font-family:"Times New Roman",serif"> </span></p>
<p class="x_xmsonormal"> </p>
</div>
</div>
</div>
</div>
</body>
</html>