serving the solutions day and night

Pages

Saturday, April 18, 2020

Azure SQL

Search Azure SQL
3 Options to Choose



Large Volume Data Migration to Azure using Azure Data Box

Migrating Large volume of data(like Terabytes or Petabytes) from on-premises to Azure using Azure Data Box.

Two types of data transfer options: Offline & Online

Offline - choose
1. More than 5 TB, no good bandwidth connectivity
2. Data can be upload to any one of storage: Block Blob, Page Blob, Managed Disk, File Storage
3. Four Data Box options available to choose 


Saturday, April 11, 2020

Docker Commands

Verify the application exist inside the windows container,  connect to the cmd of the "frontendapiwin" container using the docker exec command
1. C:\> docker exec -it 64a61d823b28  cmd
           - "64a61d823b28 " - docker container id
           - It should take us inside the container.
     Run the powershell inside the "frontendapiwin" the container 
     1.1 C:\inetpub\wwwroot> powershell 
            Using Powershell to manage application web configuration
           1.1.1 PS C:\inetpub\wwwroot> gc .\web.config   or  gc web.config 
                       - Gets the content (gc) of the item at the specified location (C:\inetpub\wwwroot\web.config)
         > [xml]$web = gc .\web.config
                         -  The [xml] casts the variable as an XML object.
                         - <?xml>
                            <configuration>
                                    <appsettings>
                                             <add key="DBCon" value="db value."/>
                                             ...
                                     </appsettings>
                                    ...
                             </configuration>
         > $web.configuration.appSettings.SelectNodes("add[@key='DBCon']")
                           - display DBCon key value
                           -  key                 value
                              -----                 -------
                               DBCon        db value.
         > $key=$web.configuration.appSettings.SelectNodes("add[@key='DBCon']")
                           - assign to key
         > $key
                           - another way display DBCon key value
         > $key.SetAttribute("value","db value changed.")
                           - change DBCon value
         > $web.save(".\web.config")
                           - save file
         > exit  => exit from powershell
           > exit  = exit from container

Sunday, February 2, 2020

ASP.NET CORE and Docker

Command to see the installed docker version

docker --version

Commands to list docker images  - display the repository name, a tag that usually specifies the repository version, image ID, creation date and size

Thursday, January 30, 2020

Add SQL Server 2017 Docker Container to ASP.NET Core MVC/Web API Project

SQL Server 2017 is available for both Windows and Linux Containers. 

            docker pull mcr.microsoft.com/mssql/server


  • Verify SQL Server 2017 image was successfully pulled locally using "docker images" cmd

Tuesday, November 5, 2019

Deploy ASP.NET CORE WEB API to Containers and Azure Kubernetes using Concourse pipeline

GitHub Source Code
https://github.com/mkader/ConcourseAzureBlobContainerK8s



1. Create and Pull ASP.NET Core WEB API source code from GitHub using Concourse resource. 2. Running unit test using Concourse job. 3. Generate a Docker Container image. 4. Publishing it into a Azure Container Registry. 5. Generate a tar(zip) file 6. Store it into a Azure Blob Storage. 7. Generate semantic version and tag it into Docker Container image. 8. Deploys a Docker Container image from Azure Container Registry to Azure Kubernetes. 9. Add Coverlet Code coverage and SonarQube Code Analysis.

Thursday, November 9, 2017

PowerShell - MS Dynamics CRM CRUD Operations

Please refer Read App.Config -
Please refer Connect MS Dynamics CRM

$crm_service = Invoke-CRMConn -OrganizationUrl $crm_organization_url -UserName $crm_username -Password $crm_password

## 1. To test the connection, check who you are:
function WhoAMI() {
    $request = new-object Microsoft.Crm.Sdk.Messages.WhoAmIRequest
    $crm_service.Execute($request)

    <#
    UserId         : 0dc96a70-952d-e611-80f0-0050568c6c1c
    BusinessUnitId : a6099f28-952d-e611-80ec-0050568c6c1c
    OrganizationId : 0d67a31e-952d-e611-80ec-0050568c6c1c
    ResponseName   : WhoAmI
    Results        : {[UserId, 0dc96a70-952d-e611-80f0-0050568c6c1c], [BusinessUnitId, a6099f28-0caf-e611-80ec-0050568c6c1c],
                     [OrganizationId, 0d67a31e-0caf-e611-80ec-0050568c6c1c]}
    ExtensionData  : System.Runtime.Serialization.ExtensionDataObject
    #>
}

PowerShell - Connect MS Dynamics CRM

## create crm connction function, call this function with arguments  OrganizationURL, UserName, Password
function Invoke-CRMConn {
    ## pass arguments OrganizationURL, UserName, Password
    [CmdletBinding()]
    param(
        [Parameter(Position=0, Mandatory=$true)] [string]$OrganizationURL,
        [Parameter(Position=1, Mandatory=$true)] [string]$UserName,
        [Parameter(Position=2, Mandatory=$true)] [string]$Password
    )

    ## get directory path
    $current_directory =  $(Get-Item ($MyInvocation.ScriptName)).DirectoryName
   
    ## load crm & xrm dll
    $xrm_dll = $current_directory + "/microsoft.xrm.sdk.dll"
    $crm_dll = $current_directory + "/microsoft.crm.sdk.proxy.dll"
    [void][System.Reflection.Assembly]::LoadFile($xrm_dll)
    [void][System.Reflection.Assembly]::LoadFile($crm_dll)
    [void][System.Reflection.Assembly]::LoadWithPartialName("system.servicemodel")

    ## create credentials
    $clientCredentials = new-object System.ServiceModel.Description.ClientCredentials
    $clientCredentials.UserName.UserName = $UserName
    $clientCredentials.UserName.Password = $Password
   
    ## create  organization service proxy 
    $service = new-object Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy($OrganizationURL, $null, $clientCredentials, $null)
   
    ## use default crm time out or set 5 minutes of timeout.
    #$service.Timeout = new-object System.Timespan(0, 5, 0)

    ## return service
    return $service
}

## test the service using who i am request
$service1 = Invoke-CRMConn -OrganizationURL "https://dns.com/XRMServices/2011/Organization.svc" -UserName 'test@dns.com' -Password ABC123!@#'
$request = new-object Microsoft.Crm.Sdk.Messages.WhoAmIRequest
$service1.Execute($request)

<#
UserId             : 123ddfa0-9534-f234-8780-78900568c2fc0
BusinessUnitId : 456a043cf-0c34-e234-878c-78900568c6c1c
OrganizationId : 7895b3c2-0c34f-e234-878c-7890568c6c1c
ResponseName   : WhoAmI
Results        : {[UserId, 123ddfa0-952d-f234-8780-7890568c6c1c], [BusinessUnitId, 456a043cf-0caf-e234-8780-7890568c6c1c],
                 [OrganizationId, 7895b3c2-0caf-e234-8780-7890568c6c1c]}
ExtensionData  : System.Runtime.Serialization.ExtensionDataObject
#>

PowerShell - Read App.config

## get current directory
$current_directory =  $(Get-Item ($MyInvocation.MyCommand.Path)).DirectoryName

## $MyInvocation.MyCommand.Path won't work if you call inside the function.
## so use ScriptName to get currect directory
$current_directory =  $(Get-Item ($MyInvocation.ScriptName)).DirectoryName

## path of config file
$app_config_path = $current_directory + "\App.config"

## reading configuration file
$xml_doc = [Xml](Get-Content $app_config_path)

## get appsettings value
$app_nodes = $xml_doc.configuration.appSettings.add
$url = ($app_nodes | where {$_.key -eq 'Url'}).value
$username = ($app_nodes | where {$_.key -eq 'UserName'}).value
$password = ($app_nodes | where {$_.key -eq 'Password'}).value

## get dbconnection setting
$con_nodes = $xml_doc.configuration.connectionStrings.add
$db_con = ($con_nodes | where {$_.name -eq 'DBConnectionString'}).connectionString

## display value
Write-Host  $url
Write-Host  $username
Write-Host  $password
Write-Host  $db_con

<#
App.config file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="Url" value="https://dns.com/Services/2017/Organization.svc" />
    <add key="UserName" value="mak@dns.com"/>
    <add key="Password" value="ABC123456!@#"/>
  </appSettings>
  <connectionStrings>
    <add name="DBConnectionString" connectionString="Data Source=MAK12345.dns.com,1044;Initial Catalog=COS_SVC;User ID=root; Password=DEF456$%^;" providerName="System.Data.SqlClient"/>
  </connectionStrings>
</configuration>
#>

Wednesday, November 8, 2017

PowerShell Dictionary

1.Create empty dictionary
$contacts = @{}

2.Add key,value item
## Way 1:
$key = 1
$value = 'CRM'
$contacts.add( $key, $value )

## Way 2:
$contacts.add( 2, 'C#' )

## Way 3:
$contacts[3]='.NET'

## Way 4 - Keys are just strings
$contacts = @{
    'full name' = 'C# Code'
    '#' = 1234
}
$contacts['full name'] # OR  $contacts.'full name' OR $key = 'full name' $contacts.$key
<#
    C# Code
#>

## Creating dictionary with values
$contacts = @{
    1 = 'CRM'
    2 = 'C#'
    31 = '.NET'
}
$contacts[4]='Azure'
$contacts[5]='Cloud'

## print contact dictionary
$contacts
<#
    Name                           Value                                                                                                   
    ----                           -----                                                                                                   
    5                              Cloud                                                                                                   
    4                              Azure                                                                                                   
    31                             .NET                                                                                                     
    2                              C#                                                                                                       
    1                              CRM
#>

$contacts_age = @{
    1 = 10
    2 = 20
    3 = 25
}