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

Visual programming with hardware and Node-RED

A good podcast about node-red from the creators.

JS Party 95: Visual programming with hardware and Node-RED – Listen on Changelog.com

BigQuery with .NET Core

Here is a sample respository ready to be injected to a ASP.NET Core application.

   public class SelfViewRepository : ISelfViewRepository
    {
        private readonly string _projectId;
        private readonly GoogleCredential _gcpCredential;

        public SelfViewRepository(string projectId, string credentialFile)
        {
            _projectId = projectId;
            _gcpCredential = GoogleCredential.FromFile(credentialFile);
        }

        public async Task<BigQueryResults> GetData(string query)
        {
            BigQueryClient client = BigQueryClient.Create(_projectId, _gcpCredential);

            BigQueryJob job = client.CreateQueryJob(
                sql: query,
                parameters: null,
                // options: new QueryOptions {UseQueryCache = false});
                options: new QueryOptions { });
            var data = await job.GetQueryResultsAsync();
            // Wait for the job to complete.
            job.PollUntilCompleted();
            // Display the results
            return data;
        }
    }

#googlecloud #bigquery #aspnetcore

JSON Type with MySQL & EF Core

As of MySQL 5.7.8, it has support for Json type. Setting the column type to json would do the job.

  [Column(TypeName = "json")]
  public string Settings{ get; set; }

Or with fluent api:

       modelBuilder.Entity<Blog>(eb =>
        {
            eb.Property(b => b.Settings).HasColumnType("json");
        });

If you send an invalid JSON, MySQL will throw an error of “Invalid JSON text”.
Details on usage are in the official documentation:
https://dev.mysql.com/doc/refman/5.7/en/json.html

In the case of custom objects, Pomelo has a feature as well: https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/14

A nive tutorial from scotch.io:
https://scotch.io/tutorials/working-with-json-in-mysql

#json #mysql #mysqlJson #efcore

Google translate in google sheets

https://support.google.com/docs/answer/3093331?hl=en&dark=1

Gif from: https://jakemiller.net/translate-in-google-sheets/

#GoogleSheets #GoogleTranslate

gcloud basics cheat sheet

GCloud Cheat Sheet:

App Deploy

  • gcloud app deploy ~/my_app/app.yaml
    [Resource]

List Versions

  • gcloud app versions list
  • JSON: gcloud app versions list --format json

List services

Delete services:

gcloud app services delete
[Resource]

List versions

  • “`gcloud app versions list“
  • Powershellgcloud app versions list --format json | ConvertFrom-Json
    [Resource]

Delete Versions

  • gcloud app versions delete

Read logs / tail

  • Read: gcloud app logs read
    [Resource]
  • Tail: gcloud app logs tail
  • Tail: gcloud app logs read --limit 10 --service=default
  • Tail: gcloud app logs read --version=v1
    [Resource]

Deploy google function with node

gcloud functions deploy pplusFunction --runtime nodejs8 --trigger-http

Split Traffic

To send all traffic to ‘v2’ of service ‘s1’, run:
gcloud app services set-traffic s1 –splits v2=1
To split traffic evenly between ‘v1’ and ‘v2’ of service ‘s1’, run:
gcloud app services set-traffic s1 –splits v2=.5,v1=.5