title: azure function using pyodbc works fine on local machine, but not on azure cloud
body: <p>I developed a simple python Azure function app using pyodbc to select a few rows from a public IP MS SQL server. My function app runs fine on my laptop, but it doesn't work when I publish it on Azure cloud (I used Consumption - serverless plan, linux environment). Thru the logging, I knows that it always gets stuck at the pyodbc.connect(...) command and time-out.</p>
  <pre><code>#...
  conn_str = f'Driver={driver};Server={server},{port};Database={database};Uid={user};Pwd={password};Encrypted=yes;TrustServerCertificate=no;Connection Timeout=30'
  sql_query = f'SELECT * FROM {table_name}'
  try:
      conn = pyodbc.connect(conn_str) # always time-out here if running on Azure cloud!!!
      logging.info(f'Inventory API - connected to {server}, {port}, {user}.')
  except Exception as error:
      logging.info(f'Inventory API - connection error: {repr(error)}.')
  else:
      with conn.cursor() as cursor:
          cursor.execute(sql_query)
          logging.info(f'Inventory API - executed query: {sql_query}.')
          data = []
          for row in cursor:
              data.append({'Sku' : row.Sku, 'InventoryId' : row.InventoryId, 'LocationId' : row.LocationId, 'AvailableQuantity' : row.AvailableQuantity})
  #...
  </code></pre>
  <p>The logging captured:</p>
  <pre><code>Inventory API - connection error: OperationalError('HYT00', '[HYT00] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)').
  </code></pre>
  <p>I already include the pyodbc in the requirements.txt file. I also allows all outboundIpAddresses and possibleOutboundIpAddresses of my function app on my SQL server firewall. My function app does not have any network restriction on Azure cloud (or at least it said so on the network settings).</p>
  <p>my config file:</p>
  <pre><code>driver={ODBC Driver 17 for SQL Server}
  server=I tried both IP and full internet host name, both didn't work
  </code></pre>
  <p>Could someone give me a hint? Thanks.</p>