{"id":640,"date":"2020-11-30T21:38:53","date_gmt":"2020-12-01T05:38:53","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/azure-sql\/?p=640"},"modified":"2020-11-30T21:38:53","modified_gmt":"2020-12-01T05:38:53","slug":"seasons-of-serverless-challenge-1-azure-functions-and-azure-sql-database-serverless","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/azure-sql\/seasons-of-serverless-challenge-1-azure-functions-and-azure-sql-database-serverless\/","title":{"rendered":"Seasons of Serverless Challenge 1: Azure Functions and Azure SQL Database serverless"},"content":{"rendered":"<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/banner-1.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-641\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/banner-1.png\" alt=\"Cover image for #SeasonsOfServerless Solution 1: Developing &quot;The Perfect Holiday Turkey&quot;\" width=\"2134\" height=\"771\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/banner-1.png 2134w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/banner-1-300x108.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/banner-1-1024x370.png 1024w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/banner-1-768x277.png 768w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/banner-1-1536x555.png 1536w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/banner-1-2048x740.png 2048w\" sizes=\"(max-width: 2134px) 100vw, 2134px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Have you heard about the Seasons of Serverless challenge? Join the <a href=\"https:\/\/dev.to\/azure\/azure-advocates-seasons-of-serverless-join-our-virtual-festive-potluck-53m6\" target=\"_blank\" rel=\"noopener noreferrer\">festive virtual potluck<\/a> by creating solutions to challenges leveraging Azure serverless computing. Throughout the next seven weeks we&#8217;ll be sharing a solution to the week&#8217;s challenge that integrates <a href=\"https:\/\/docs.microsoft.com\/azure\/azure-sql\/database\/serverless-tier-overview\" target=\"_blank\" rel=\"noopener noreferrer\">Azure SQL Database serverless<\/a> with Azure serverless compute.<\/p>\n<h2>Challenge 1: The Perfect Holiday Turkey \ud83e\udd83<\/h2>\n<p>The first week features the North America tradition of cooking a turkey.\u00a0 The challenge calls for converting a brine recipe based on the input weight of a turkey and recommends leveraging an Azure Function to generate the recipe.\u00a0 Below is a high level view of the solution we created, utilizing an Azure Function and Azure SQL Database serverless.\u00a0 The completed example can be found on <a href=\"https:\/\/github.com\/dzsquared\/seasons-of-serverless-week1\" target=\"_blank\" rel=\"noopener noreferrer\">GitHub<\/a>.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/overview-week1.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-644\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/overview-week1.png\" alt=\"Azure function sending weight of turkey to Azure SQL, Azure SQL returning JSON recipe\" width=\"928\" height=\"219\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/overview-week1.png 928w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/overview-week1-300x71.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/overview-week1-768x181.png 768w\" sizes=\"(max-width: 928px) 100vw, 928px\" \/><\/a><\/p>\n<hr \/>\n<h3>Creating an Azure Function in VS Code<\/h3>\n<p>Using the VS Code Azure Functions extension and the &#8220;Azure Functions: Create New Project&#8221; command, we&#8217;re creating a new Azure Function locally in VS Code in Python with the HTTP trigger template.\u00a0 This function will receive HTTP GET requests with a turkey size in pounds (lbs) through a query string parameter.\u00a0 The body of the function is defined in the <strong>main(req: func.HttpRequest)<\/strong> function in the file <strong>__init__.py<\/strong>.\u00a0 Dependencies for our function that need to be installed to run the function are detailed in the file\u00a0<strong>requirements.txt<\/strong>, where we want to begin by adding a line for <em>pyodbc<\/em>. <a href=\"https:\/\/docs.microsoft.com\/sql\/connect\/python\/pyodbc\/python-sql-driver-pyodbc\" target=\"_blank\" rel=\"noopener noreferrer\">pyodbc<\/a> is an open-source module for Python that enables connecting to ODBC databases, including Azure SQL and Microsoft SQL Server.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/function-outline.png\"><img decoding=\"async\" class=\"alignleft wp-image-650\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/function-outline.png\" alt=\"function outline: getSqlConnection, getIngredients, generateHttpResponse\" width=\"400\" height=\"243\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/function-outline.png 743w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/function-outline-300x182.png 300w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a>Our Python function will utilize 3 internal functions,\u00a0<strong>getSqlConnection, getIngredients,\u00a0<\/strong>and\u00a0<strong>generateHttpResponse<\/strong>.\u00a0 The first,\u00a0<strong>getSqlConnection,<\/strong> implements the initial connection of the pyodbc driver to our database based on the connection string retrieved from the application settings. Since we are implementing our project on the serverless tier of Azure SQL database, we need our function to be able to gracefully handle instances when our database has autopaused.\u00a0 Login events are one of the events that trigger <a href=\"https:\/\/docs.microsoft.com\/azure\/azure-sql\/database\/serverless-tier-overview#autoresuming\" target=\"_blank\" rel=\"noopener noreferrer\">autoresume<\/a>, so our function needs to try the pyodbc.connect() call again if a database connection error is encountered.<\/p>\n<pre class=\"prettyprint\">def getSqlConnection(sqlConnectionString):\r\n    i = 0\r\n    while i &lt; 6:\r\n        logging.info('contacting DB')\r\n        try:\r\n            sqlConnection = pyodbc.connect(sqlConnectionString)\r\n        except pyodbc.DatabaseError:\r\n            time.sleep(10) # wait 10s before retry\r\n            i+=1\r\n        else:\r\n            return sqlConnection<\/pre>\n<p>Once the database has successfully connected, we will ask the database to send us back the ingredients. One of the many developer-friendly features of Azure SQL is how quickly it can create JSON in query results, so we have quick work of implementing handling our database results:<\/p>\n<pre class=\"prettyprint\">def getIngredients(sqlConnection, turkeySize):\r\n    logging.info('getting ingredients')\r\n    results = []\r\n    sqlCursor = sqlConnection.cursor()\r\n    sqlCursor.execute('EXEC calculateRecipe '+str(turkeySize))\r\n    results = json.loads(sqlCursor.fetchone()[0])\r\n    sqlCursor.close()\r\n    return results<\/pre>\n<p>The full code for the Azure Function <strong>__init__.py<\/strong> is available <a href=\"https:\/\/github.com\/dzsquared\/seasons-of-serverless-week1\/blob\/main\/week1-function\/HttpTrigger1\/__init__.py\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>.<\/p>\n<hr \/>\n<h3>Creating and Building the Azure SQL Database<\/h3>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/serverless-db-setup.png\"><img decoding=\"async\" class=\"alignright size-medium wp-image-663\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/serverless-db-setup-300x262.png\" alt=\"Azure portal serverless db setup\" width=\"300\" height=\"262\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/serverless-db-setup-300x262.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/serverless-db-setup.png 728w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><a href=\"https:\/\/docs.microsoft.com\/azure\/azure-sql\/database\/serverless-tier-overview\" target=\"_blank\" rel=\"noopener noreferrer\">Azure SQL database serverless<\/a> is a compute tier for SQL databases that automatically pauses and scales based on the current workload. Similar to Azure Functions, not only does Azure SQL database serverless have the capability to automatically scale with your workload, but you can build your solution locally once and deploy it to one or more instances.<\/p>\n<p>Starting from the <a href=\"https:\/\/portal.azure.com\/#create\/Microsoft.SQLDatabase\" target=\"_blank\" rel=\"noopener noreferrer\">Create SQL Database<\/a> pane in the Azure Portal, we provide a new database name and can leverage an existing or new server.\u00a0 The option to configure <strong>Compute + storage<\/strong> should be adjusted to select the <strong>Serverless<\/strong> compute tier.\u00a0 When using another Azure resource with an Azure SQL database, such as Azure Functions, it is important to permit network access between them.\u00a0 This option is commonly referred to as &#8220;Allow Azure services and resources to access this server&#8221; and is <a href=\"https:\/\/docs.microsoft.com\/azure\/azure-sql\/database\/network-access-controls-overview#allow-azure-services\" target=\"_blank\" rel=\"noopener noreferrer\">set at the server level<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<h4>SQL Database Projects in Azure Data Studio<\/h4>\n<p><img decoding=\"async\" class=\"alignright wp-image-646 size-medium\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/create-new-project-e1606774256401-221x300.png\" alt=\"create new project dialog for week1-db\" width=\"221\" height=\"300\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/create-new-project-e1606774256401-221x300.png 221w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/create-new-project-e1606774256401.png 309w\" sizes=\"(max-width: 221px) 100vw, 221px\" \/><\/p>\n<p>After provisioning a serverless tier Azure SQL database through the Azure Portal, we start by creating the database structures in <a href=\"http:\/\/aka.ms\/azuredatastudio\" target=\"_blank\" rel=\"noopener noreferrer\">Azure Data Studio<\/a> with the <a href=\"https:\/\/aka.ms\/azuredatastudio-sqlprojects\" target=\"_blank\" rel=\"noopener noreferrer\">SQL Database projects extension<\/a>.\u00a0 To begin, we create a new database project in Azure Data Studio.\u00a0 The database schema we&#8217;ve designed is relatively simple, we need a <strong>table to store the ingredients<\/strong> for the given recipe and a <strong>stored procedure to return the recipe<\/strong> scaled based on an input turkey size.\u00a0 We create these objects in the database project by right-clicking the project or desired folder in the project and selecting &#8220;Add Table&#8221; and &#8220;Add Stored Procedure&#8221;.<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"prettyprint\">CREATE TABLE [dbo].[Ingredients]\r\n(\r\n  IngredientName NVARCHAR(200) NOT NULL PRIMARY KEY,\r\n  UnitofMeasure NVARCHAR(20) NOT NULL,\r\n  RatioToTurkeyLBs DECIMAL(10,4) NOT NULL\r\n);\r\nGO\r\n<\/pre>\n<p>As previously mentioned, we want our stored procedure to return JSON to the Azure Function. No problem! Using <em>FOR JSON PATH<\/em> in our stored procedure query bundles the rows into a JSON array.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/forjsonpath.png\"><img decoding=\"async\" class=\"aligncenter wp-image-653 size-full\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/forjsonpath.png\" alt=\"query results in table format arrow for json path to json results\" width=\"1128\" height=\"548\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/forjsonpath.png 1128w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/forjsonpath-300x146.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/forjsonpath-1024x497.png 1024w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/forjsonpath-768x373.png 768w\" sizes=\"(max-width: 1128px) 100vw, 1128px\" \/><\/a><\/p>\n<pre class=\"prettyprint\">CREATE PROCEDURE [dbo].[calculateRecipe]\r\n\u00a0\u00a0@turkeySize DECIMAL(10,5)\r\nAS\r\nBEGIN\r\n\u00a0\u00a0SELECT IngredientName, UnitofMeasure,\r\n\u00a0\u00a0\u00a0\u00a0cast(round((RatioToTurkeyLBs*@turkeySize),2) as decimal(6,2)) AS IngredientAmount\r\n\u00a0\u00a0FROM Ingredients\r\n\u00a0\u00a0FOR JSON PATH\r\nEND<\/pre>\n<p>After adding both of these objects, we&#8217;re well on our way to creating our serverless database! We do have 1 more thing to add to our database project &#8211; the recipe.\u00a0 By adding a &#8220;Post-Deployment Script&#8221; to our project, we&#8217;re adding some T-SQL that will execute after the project has published to the database.\u00a0 We can add a script that inserts the values for the ingredients to the Ingredients table.<\/p>\n<pre class=\"prettyprint\">DELETE FROM INGREDIENTS;\r\nGO\r\n\r\nINSERT INTO INGREDIENTS (INGREDIENTNAME, UNITOFMEASURE, RATIOTOTURKEYLBS)\r\nVALUES ('Salt', 'cups', 0.05), ('Water', 'gal', 0.66),\r\n    ('Brown sugar', 'cups', 0.13), ('Shallots', 'each', 0.2),\r\n    ('Garlic', 'cloves', 0.4), ('Whole peppercorns','tbsp', 0.13),\r\n    ('Dried juniper berries', 'tbsp', 0.13), ('Fresh rosemary','tbsp', 0.13),\r\n    ('Thyme', 'tbsp', 0.06), ('Brine time','hours', 2.4),\r\n    ('Roast time','minutes', 15);\r\nGO<\/pre>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/publish-from-azuredatastudio.png\"><img decoding=\"async\" class=\"alignright wp-image-656\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/publish-from-azuredatastudio.png\" alt=\"publish dialog from azure data studio\" width=\"400\" height=\"216\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/publish-from-azuredatastudio.png 500w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/publish-from-azuredatastudio-300x162.png 300w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a>To deploy these objects to our Azure SQL database, we will build and publish the project to the serverless tier database we created in Azure.\u00a0 Right-clicking on the database project in Azure Data Studio\u00a0 After publishing the project from Azure Data Studio to the Azure SQL database, the database is all set!\u00a0 You might have noticed some new files in the folder under bin\\Debug are created during project build.\u00a0 The .<em>dacpac<\/em> file is a data-tier application, a file that contains the database objects we created and can be published one or many times.\u00a0 In future challenges we will dig into how to leverage automation to deploy our database solutions as we will do for the Azure Function below.<\/p>\n<p>&nbsp;<\/p>\n<hr \/>\n<h3>Deploying the Azure Function<\/h3>\n<p>The Azure Function that we created earlier in this post in the local VS Code environment can be deployed to Azure directly from our GitHub repository.\u00a0 This will enable continuous deployments to Azure from our future code changes.\u00a0 We will create an Azure Function App in the Portal to publish our code to on the Python runtime stack, and once it is created we need to download the publish profile from the overview page. Treat the publish profile like a password &#8211; it allows privileged access to manage the function and we&#8217;re going to use it to allow GitHub to publish our code as a function.<a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/get-publish-profile.png\"><img decoding=\"async\" class=\"size-full wp-image-667 aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/get-publish-profile.png\" alt=\"Publish profile available for download on Azure Function overview page\" width=\"814\" height=\"130\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/get-publish-profile.png 814w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/get-publish-profile-300x48.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/get-publish-profile-768x123.png 768w\" sizes=\"(max-width: 814px) 100vw, 814px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Before we leave the Function App in the Azure Portal, we should add the Azure SQL serverless connection string to the <strong>Application settings<\/strong> such that the function can access it through an environment variable.\u00a0 In a Python Azure Function this is written <em>o<\/em><span style=\"font-size: 1rem\"><em>s.environ[&#8220;serverlessdb&#8221;]<\/em> for the application setting named &#8220;serverlessdb&#8221;.\u00a0 The full connection string for the value is in the format:<\/span><\/p>\n<pre class=\"prettyprint\">DRIVER={ODBC Driver 17 for SQL Server};SERVER=yourservernamehere.database.windows.net;PORT=1433;DATABASE=yourdatabasenamehere;UID=sqladmin;PWD=yourpasswordhere<\/pre>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/application-setting.png\"><img decoding=\"async\" class=\"alignright size-full wp-image-659\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/application-setting.png\" alt=\"Azure function application setting with serverlessdb as the bottom entry with SQL connection string\" width=\"956\" height=\"572\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/application-setting.png 956w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/application-setting-300x179.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/application-setting-768x460.png 768w\" sizes=\"(max-width: 956px) 100vw, 956px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>This method stores the password for a database user in clear text and it is visible to anyone with access to this pane in the Azure Portal. You are encouraged to consider additional security in full scale implementations, such as Azure Key Vault or utilizing limited permission SQL users (seen in the <a href=\"https:\/\/github.com\/dzsquared\/seasons-of-serverless-week1\/blob\/main\/week1-db\/Script.PostDeploymentIngredients.sql\" target=\"_blank\" rel=\"noopener noreferrer\">sample<\/a>).<\/p>\n<p>Want to test your Azure Function locally? Place the same application setting for the database connection string in the <strong>local.settings.json <\/strong>file under &#8220;Values&#8221;.<\/p>\n<h4>GitHub Action<\/h4>\n<p>We need to add the contents of the publish profile to our GitHub repository as a secret (under Settings&gt;Secrets) for <em>AZURE_FUNCTIONAPP_PUBLISH_PROFILE<\/em>.\u00a0 This value can now be used in GitHub actions to access the Azure Function App.\u00a0 The <a href=\"https:\/\/github.com\/Azure\/functions-action\" target=\"_blank\" rel=\"noopener noreferrer\">Azure Functions action<\/a> handles the deployment for us and even provides samples for several runtimes, including Python.\u00a0 To leverage <a href=\"https:\/\/github.com\/Azure\/actions-workflow-samples\/blob\/master\/FunctionApp\/linux-python-functionapp-on-azure.yml\" target=\"_blank\" rel=\"noopener noreferrer\">their sample<\/a>, add the code to the .github\/workflows folder in your project and update the <em>env<\/em> variables at the top of the script.\u00a0 In our instance, it&#8217;s in a file named <a href=\"https:\/\/github.com\/dzsquared\/seasons-of-serverless-week1\/blob\/main\/.github\/workflows\/main.yml\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>main.yml<\/strong><\/a>.\u00a0 The action leverages a cloud environment to:<\/p>\n<ul>\n<li>remotely checkout (grab) your code<\/li>\n<li>setup a Python environment and install dependencies (remember the requirements.txt file?)<\/li>\n<li>deploy the environment to your Azure Function<\/li>\n<\/ul>\n<p>You can track the progress of the deployment after you push code under the <strong>Actions<\/strong> tab in the GitHub repo.<\/p>\n<hr \/>\n<h2>Wrapping Up<\/h2>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/test-output.png\"><img decoding=\"async\" class=\"alignright size-medium wp-image-672\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/test-output-288x300.png\" alt=\"Image test output\" width=\"288\" height=\"300\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/test-output-288x300.png 288w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/test-output-768x800.png 768w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2020\/11\/test-output.png 778w\" sizes=\"(max-width: 288px) 100vw, 288px\" \/><\/a>Once the Azure Function code has deployed to Azure, we are able to test the Function in the Azure Portal or via a REST client such as Postman. If there&#8217;s a change in the recipe, the database can be updated to return different ingredients or amounts.\u00a0 Since both our compute and database are serverless, our costs are minimized when there is no workload.\u00a0 For the database, we are only charged for storage when the database is paused.\u00a0 Next time you need a database for your serverless architecture, consider Azure SQL database serverless.\u00a0 See you next week for our solution to <a href=\"https:\/\/github.com\/microsoft\/Seasons-of-Serverless\/blob\/main\/Nov-30-2020.md\" target=\"_blank\" rel=\"noopener noreferrer\">Challenge 2: Lovely Ladoos<\/a>!<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Throughout the next seven weeks we&#8217;ll be sharing a solution to the week&#8217;s Seasons of Serverless challenge that integrates Azure SQL Database serverless with Azure serverless compute. Learn how to develop an Azure Function that leverages Azure SQL database serverless with Challenge 1 of the Seasons of Serverless challenge.<\/p>\n","protected":false},"author":46830,"featured_media":641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1,411],"tags":[],"class_list":["post-640","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure-sql","category-python"],"acf":[],"blog_post_summary":"<p>Throughout the next seven weeks we&#8217;ll be sharing a solution to the week&#8217;s Seasons of Serverless challenge that integrates Azure SQL Database serverless with Azure serverless compute. Learn how to develop an Azure Function that leverages Azure SQL database serverless with Challenge 1 of the Seasons of Serverless challenge.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/posts\/640","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/users\/46830"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/comments?post=640"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/posts\/640\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/media\/641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/media?parent=640"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/categories?post=640"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/tags?post=640"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}