Azure – Application Settings and Connection Strings

Resources for storing connection string and application string in azure apps.

  1. https://azure.microsoft.com/es-es/blog/windows-azure-web-sites-how-application-strings-and-connection-strings-work/
  2. https://mderriey.com/2018/08/21/azure-app-service-connection-strings-and-asp-net-core/
  3. https://docs.microsoft.com/en-ca/azure/app-service/configure-common#connection-strings
  4. https://docs.microsoft.com/en-ca/azure/app-service/app-service-key-vault-references

#azure #azure-database

Azure SQL Database (MSSQL) -…

Azure SQL Database (MSSQL) – Working with JSON Data

SELECT

SELECT Name, Surname,
  JSON_VALUE(jsonCol, '$.info.address.PostCode') AS PostCode,
  JSON_VALUE(jsonCol, '$.info.address."Address Line 1"') + ' '
  + JSON_VALUE(jsonCol, '$.info.address."Address Line 2"') AS Address,
  JSON_QUERY(jsonCol, '$.info.skills') AS Skills
FROM People
WHERE ISJSON(jsonCol) > 0
  AND JSON_VALUE(jsonCol, '$.info.address.Town') = 'Belgrade'
  AND Status = 'Active'
ORDER BY JSON_VALUE(jsonCol, '$.info.address.PostCode')

Modify

 
DECLARE @json NVARCHAR(MAX);
SET @json = '{"info": {"address": [{"town": "Belgrade"}, {"town": "Paris"}, {"town":"Madrid"}]}}';
SET @json = JSON_MODIFY(@json, '$.info.address[1].town', 'London');
SELECT modifiedJson = @json;

Convert JSON collections to a rowset

DECLARE @json NVARCHAR(MAX);
SET @json = N'[
  {"id": 2, "info": {"name": "John", "surname": "Smith"}, "age": 25},
  {"id": 5, "info": {"name": "Jane", "surname": "Smith"}, "dob": "2005-11-04T12:00:00"}
]';

SELECT *
FROM OPENJSON(@json)
  WITH (
    id INT 'strict $.id',
    firstName NVARCHAR(50) '$.info.name',
    lastName NVARCHAR(50) '$.info.surname',
    age INT,
    dateOfBirth DATETIME2 '$.dob'
  );
 

Resources & more:

  1. https://cloudblogs.microsoft.com/sqlserver/2016/01/05/json-in-sql-server-2016-part-1-of-4/
  2. https://channel9.msdn.com/Shows/Data-Exposed/SQL-Server-2016-and-JSON-Support
  3. https://azure.microsoft.com/es-es/blog/json-support-is-generally-available-in-azure-sql-database/
  4. https://docs.microsoft.com/en-us/sql/relational-databases/json/json-data-sql-server?view=sql-server-ver15
  5. https://docs.microsoft.com/en-us/sql/relational-databases/json/store-json-documents-in-sql-tables?view=sql-server-ver15
  6. https://docs.microsoft.com/en-us/sql/relational-databases/json/index-json-data?view=sql-server-ver15

MySQL from version 5.7 has JSON support: https://www.sitepoint.com/use-json-data-fields-mysql-databases/

#azure #azure-database #json #mssql-json

Whenever you publish a webjob,…

Whenever you publish a webjob, it is located under the App_Data/jobs/ {triggered or scheduled} of your App Service …
Hence, you can publish the webjobs via FTP or directly from vstudio. If you do so, settings.jobs file need to be created manually.

#azure #webjobs

Azure WebJobs

What is an Azure WebJob?  With WebJobs, you can simply run a program or script just like a running a web app. Azure Functions is also a similar service. You can create a console app and run it continuously or triggered. Let’s try a simple one.

  • Create the console app: dotnet new console
  • Write your code. Console.WriteLine outputs to WebJobs logs page. So you can use that to log simply.
  • Publish the project: dotnet publish -c Release
  • Add a new file with extension .cms, such as Run.cmd in the publish folder – we do this because webjobs do not run dll files directly. It will run this script file.
  • Add the command to run your dll: dotnet YourProject.dll
  • Zip the publish file: YourPorject.zip
  • Follow these steps to upload it to Azure and run it: https://docs.microsoft.com/en-us/azure/app-service/web-sites-create-web-jobs
  • You can use CRON expression for triggered jobs:

Every 15 minutes: 0 */15 * * * *
Every hour (that is, whenever the count of minutes is 0): 0 0 * * * *
Every hour from 9 AM to 5 PM: 0 0 9-17 * * *
At 9:30 AM every day: 0 30 9 * * *
At 9:30 AM every weekday: 0 30 9 * * 1-5

For more advanced features, you can use WebJobs SDK:
https://github.com/Azure/azure-webjobs-sdk

Resources:

WebJobs:
https://docs.microsoft.com/en-us/azure/app-service/web-sites-create-web-jobs

WebJobs vs. Functions:
https://docs.microsoft.com/en-us/azure/azure-functions/functions-compare-logic-apps-ms-flow-webjobs

http://www.hanselman.com/blog/IntroducingWindowsAzureWebJobs.aspx

CRON Expressions Cheat Sheet:
https://codehollow.com/2017/02/azure-functions-time-trigger-cron-cheat-sheet/

#azure #azure-functions, #azure-webjobs, #webjobs