Saturday, October 13, 2018

WINDOWS POWERSHELL COMMANDS

WINDOWS POWERSHELL COMMANDS

Open your power shell from command prompt as a administrator.

Point to remember : Declare any variable with $y in PowerShell


C:\WINDOWS\system32>$array ="India","Japan","Aus","US","UK"

C:\WINDOWS\system32> $array

It will list an array


PS C:\WINDOWS\system32> $array[2]

It gives value on index 2 , which is AUS in our case.


image

$array=("India","Asia"),("Japan","Asia"),("AUstralia","Australia"),("UK","EUROPE"),("US","North America”)

PS C:\WINDOWS\system32> $array

PS C:\WINDOWS\system32> $array[0][1]
Asia
PS C:\WINDOWS\system32> $array[1][1]
Asia
PS C:\WINDOWS\system32> $array[1][0]


======================================

Some mathematical commands show below:

PS C:\WINDOWS\system32> $y=get-service
PS C:\WINDOWS\system32> $y.count
292
PS C:\WINDOWS\system32> [math]::sqrt("9")
3
PS C:\WINDOWS\system32> $x="192.78788"
PS C:\WINDOWS\system32> [math]::round($x,2)
192.79








4. To update the value of an index in array as shown below:

PS C:\WINDOWS\system32> $array[1][0]="Singapore"
PS C:\WINDOWS\system32> $array[1][0]



5. To change the variable case in upper and lower use the following command


PS C:\WINDOWS\system32> $x="The quick brown fox jumps right over the lazy little dogs"
PS C:\WINDOWS\system32> $x.ToUpper()
THE QUICK BROWN FOX JUMPS RIGHT OVER THE LAZY LITTLE DOGS
PS C:\WINDOWS\system32> $x.TOLOWER()

Output
the quick brown fox jumps right over the lazy little dogs


6. To replace any word


PS C:\WINDOWS\system32> $x.replace("The","That")
That quick brown fox jumps right over the lazy little dogs



7. To Get complete service object in a variable

Declare any variable with $y in PowerShell

PS C:\WINDOWS\system32> $y=get-service
PS C:\WINDOWS\system32> $y.count
Output : 292

Wednesday, October 10, 2018

Azure Session in Noida,India

Conducted and Executed Azure session in Noida today Some Glimpse Conversation following topics

Image result for azure images

  • Azure
    ARM Portal (Azure Resource Manager)
    Azure Service Model
    ARM Portal Deep Dive
    Platform As A Service(PaaS)
    Hosting .Net WEBAPI Application
    Application Insights
    Application Insights Telemetry
    Live Streaming of execution
    Logic Apps as WebHook
    Logic apps integration with Skype/Slack for notification
    Create Logic apps for Twitter Integration with Slack(AI Usage)
    Stay in Cloud





10 OCT 2018


@Azure @ARM @LogicApps

Sunday, October 7, 2018

POWER SHELL COMMANDS

POwer SHELL COMMANDS


get-help workerrole
get-help webrole
get-help *content*
get-help storage
get-command *event

get-eventlog system

get-eventlog system -newest 10 // to get latest 10 log
 
get-eventlog system -newest 10 | where {$_.instanceid -eq 129} // To get the specific event
 
get-eventlog system -newest 10 | where {$_.instanceid -lt 1219} // to get all events less than event id 129
  
get-service | export-csv -path E:\Service.csv -- to export all services to E drive through command 

import-csv E:\Service.csv


TO Export all process in xml format :


get-process | export-clixml -path  e:\training.xml

TO Export all process in txt format :

get-process | out-file -filepath  e:\training.txt

To open in notepad :

invoke-item  e:\training.txt


To get all service in html format:


get-service | convertto-html


get-service | convertto-html | set-content E:\xyz.xml


To retrieve only two columns from Services:


get-service | convertto-html -property name,status



List of service starts with character “S”


get-service s*


To get process which has id less than 100

get-process | where id -lt 100


To Get service which are running using where clause in powershell:


get-service | where {$_.status -eq "running"}

get-service | where {$_.status -eq "stopped"}

Thursday, September 20, 2018

Install httprepl in DotnetCore 2.2 Preview

Install httprepl in DotnetCore 2.2 Preview

While you are working on the .Net Core Preview 2.2 than you may required to  install httprepl, so while Installing dotnet-httprepl from the command prompt using the following command:

dotnet tool install -g --version 2.2.0-* --add-source https://dotnet.myget.org/F/dotnet-core/api/v3/index.json dotnet-httprepl


image


You can verify about the version installed with the following command : dotnet tool list -g


image


#ASP.NET Core

Tuesday, August 28, 2018

Difference between Cloud Service and PaaS App Service


 

In Cloud service you can take control of remote machine.
                                                                    App Service                                                       Cloud Service

App Service In app service you deploy app on FTP, App service also manages by Microsoft.

   You will deploy an application on VM means on physical server, Microsoft manages the virtual machine for us.                          
App service deployment is faster.Cloud Service Deployment process is slower because of physical service.
App service you can’t take the control or remote desktop of FTP.
In App Service you can scale up to 20 instanceWhile in Cloud Service you can scale up to 10000 instance.
However you machine can be shared among many vendors  , so it means multiple application can share same serverThere is dedicated machine in Cloud Service  Which puts you application in high availability set.
You can’t install any softwareYou can install some sort of software in VM that you can.also you can make some configuration as per you need along with utlize almost 700 resources

Thursday, July 26, 2018

Python TypeError must be str not int

Python TypeError must be str not int


While working on Modules using python using an IDE PyCharm i confronted an issue while printing int value using Print function of python.I’ve created a python module which i require to import prior to use.

Now question strikes in mind what actually Module is in Python.


I’ve craeted a fle named as Functions and having the below given code:



def calculate_square_area(length):
return length*length

The structure looks like of a sample application as shown below:

image

Monday, June 11, 2018

[Fiddler] The connection to com failed.

Error-Messages

[Fiddler] The connection to '<the site>.com' failed. 
System.Security.SecurityException Failed to negotiate HTTPS connection with server.fiddler.network.https> HTTPS handshake to <the site>.com (for #3) failed. System.IO.IOException Unable to read data from the transport connection: 
An existing connection was forcibly closed by the remote host. < An existing connection was forcibly closed by the remote host 


Resolution - 

Go to  Tools > Telerik Fiddler Options > HTTPS It's set to ;ssl3;tls1.0 Add tls1.2

Kinldy refer below image for reference.


image

Warm Regards

Sachin Kalia

Tuesday, May 8, 2018

Session about .Net Core 2.0 with Angular in Noida

Session about .Net Core 2.0 with Angular in Noida

Shared my learning about .Net Core 2.0 with Angular with it's inbuilt template and many more in Noida .
Mitigation of Challenges faced with earlier version of .Net
Some glimpse of the day
#dotnetcore2.0#Angular #mvpbuzz #asp.net



Image may contain: Sachin Kalia, standing and screen

Image may contain: Sachin Kalia, standing and screen

Image may contain: 8 people, including Chirag Arora, Vibhor Kaushik, Himanshu Dora, Dinesh Verma and Anirudh Prasad, people smiling, people sitting and indoor

Image may contain: Sachin Kalia, standing and screen


#dotnetcore #Angular

Monday, April 30, 2018

Missing Registration For Location Error while Publishing the API on Azure.

Introduction:

Missing Registration For Location Error Can come when we are trying to publish the web application on azure from Visual studio.

Solution:

I’ve tried various way to resolve this and various website advised to me to update  visual studio or Upgrading Azure SDK will resolve your problem however this didn’t work. So I used alternative approach for publishing.

Steps:


  • Publish your web application using visual studio. It gives this  error. but It creates App Service Plan and App Service in Azure.
  • sign in to portal.azure.com
  • Select the App Service which you have created.
  • image




  • Click on Get Publish Profile.
  • Now Again Go to Visual studio and Publish.




  • This time while publishing select Import.

  • image




  • Select the file which you have downloaded from azure.
  • Click Ok.
  • Click On Publish.
    image


    10. Your Application will get Publish

    #Azure

    Monday, March 26, 2018

    Abstract Factory Pattern Using C# - Real World Example

    While learning about design patterns, I came to understand the most frequently used term, Factory Pattern as well as Abstract factory pattern. I searched the internet and came across numerous learning points. After a lot of search and study, I endeavored to find an actual need for the abstract design pattern.

    In this article, I will explore this pattern in an easy way so that everyone can have a better understanding of it. Down the level, I'm using a Car (Vehicle) example to demonstrate abstract factory pattern.

    An important aspect of software design is the manner in which objects are created. Thus, it is not only important what an object does or what it models, but also in what manner it was created.

    Reference: http://www.dofactory.com/
    Definition
    Provide an interface for creating families of related or dependent objects without specifying their concrete classes.

    Definition

    C#

    I'd keep the structure in such a way as depicted below.
    Participants

    The classes and objects participating in this pattern are:

    • AbstractFactory (IVehicleFactory)
      • declares an interface for operations that create abstract products.
    • ConcreteFactory (MarutiFactory, TataFactory)
      • implements the operations to create concrete product objects.
    • AbstractProduct (ICarEngine, ICarLight)
      • declares an interface for a type of product object.
    • Product (DDis, LED, Revtron, Helogan)
      • defines a product object to be created by the corresponding concrete factory.
      • implements the AbstractProduct interface.
    • Client (Clinet)
      • uses interfaces declared by AbstractFactory and AbstractProduct classes.

    Implementation

    1. using System; 
    2. namespace AbstractFactoryPattern 
    3. interface IVehicleFactory 
    4.     { 
    5.         ICarEngine GetCarEngine(); 
    6.         ICarLight GetCarLight(); 
    7.     } 
    8. class MarutiFactory : IVehicleFactory 
    9.     { 
    10. public ICarEngine GetCarEngine() 
    11.         { 
    12. return new DDiS(); 
    13.         } 
    14. public ICarLight GetCarLight() 
    15.         { 
    16. return new LED(); 
    17.         } 
    18.     } 
    19. class TataFactory : IVehicleFactory 
    20.     { 
    21. public ICarEngine GetCarEngine() 
    22.         { 
    23. return new Revtron(); 
    24.         } 
    25. public ICarLight GetCarLight() 
    26.         { 
    27. return new Helogen(); 
    28.         } 
    29.     } 
    30. class LED : ICarLight 
    31.     { 
    32. public string GetLightInfo() 
    33.         { 
    34. return "Led lights"; 
    35.         } 
    36.     } 
    37. class DDiS : ICarEngine 
    38.     { 
    39. public string GetEngineInfo() 
    40.         { 
    41. return "DDis engine for their diesal cars..."; 
    42.         } 
    43.     } 
    44.     internal class Helogen : ICarLight 
    45.     { 
    46. public string GetLightInfo() 
    47.         { 
    48. return "Helogan Light..."; 
    49.         } 
    50.     } 
    51.     internal class Revtron : ICarEngine 
    52.     { 
    53. public string GetEngineInfo() 
    54.         { 
    55. return "Revtron engine for their diesal/petrol cars..."; 
    56.         } 
    57.     } 
    58.     internal interface ICarLight 
    59.     { 
    60.         string GetLightInfo(); 
    61.     } 
    62.     internal interface ICarEngine 
    63.     { 
    64.         string GetEngineInfo(); 
    65.     } 
    66. class Client 
    67.     { 
    68. private IVehicleFactory vehicleFactory = null; 
    69. public void CreateCarWithLight(string carName) 
    70.         { 
    71. if (carName.ToLower() == "maruti") 
    72.             { 
    73.                 vehicleFactory = new MarutiFactory(); 
    74.                 Console.Write( 
    75.                     $"{carName} uses {vehicleFactory.GetCarEngine().GetEngineInfo()} with {vehicleFactory.GetCarLight().GetLightInfo()} as headlight"); 
    76.             } 
    77. else if (carName.ToLower() == "tata") 
    78.             { 
    79.                 vehicleFactory = new TataFactory(); 
    80.                 Console.Write( 
    81.                     $"{carName} uses {vehicleFactory.GetCarEngine().GetEngineInfo()} with {vehicleFactory.GetCarLight().GetLightInfo()} as headlight"); 
    82.             } 
    83.         } 
    84.     } 
    85. class Program 
    86.     { 
    87. static void Main(string[] args) 
    88.         { 
    89.             Console.Write("**** Welcome to Abstract Factory pattern By DotnetPiper.com *******\n Kinldy enter your car name..."); 
    90.             Client client = new Client(); 
    91.             string carName = Console.ReadLine(); 
    92.             client.CreateCarWithLight(carName); 
    93.             Console.ReadLine(); 
    94.         } 
    95.     } 
    96. }

    Run your application now. The following window will appear.
    C#
    Put the desired car name you would like to know the information about, like Maruti, Tata etc.

    Kindly refer to the following window as a result after you put Maruti.
    C#


    Link to download sample application Abstract Factory Pattern Using C# - Real World Example