Author: Manjunath

Manjunath is an IT enthusiast and has an experience of 3 years in Cloud services platform. He likes to blog, addressing the problems and troubleshooting approaches of Azure services and Powershell.

Azure – Cost Management Better Than Ever Using Cloudyn (Registration)

Microsoft’s acquisition of Cloudyn will help Azure customers manage and optimize their cloud usage. Read more about the acquisition here. A message from Sharon Wagner, CEO of Cloudyn.

About Cloudyn

Azure Cost Management by Cloudyn empowers organizations to monitor cloud spend, drive organizational accountability, and optimize cloud efficiency so they can accelerate future cloud investments with confidence.

Microsoft’s acquisition of Cloudyn will help Azure customers and partners as they face the challenges of growing their multi-cloud environments. It will enable them to gain visibility, understand and optimize cloud consumption, as well as accurately project future usage.

Microsoft will continue to support multi-cloud environments, including Azure, AWS, and GCP. Azure Cost Management by Cloudyn is available for free to customers and partners managing Azure spend. Additional premium capabilities are available at no cost through June 2018, once they will become paid features.

Let us look into how to sign up to Cloudyn if you are an Azure customer

Step 1: Login to your Azure Subscription via the Azure portal. Select the “Cost Management + Billing” blade. Then select “Cost Management” from the options on the left-hand side of the pane.

Click on “Go to Cost Management”

image_1

 

Step 2: Once you click the”Go to Cost Management” button, you will be redirected to  Cloudlyn’s page to set up your Cost Management details.

Enter your organization name and the type of Azure access you have on your Azure account. I have a personal subscription, so I have chosen as “Azure Individual Subscription Owner.”

image_2

 

Step 3: Cloudlyn Account name and Tenant ID will be automatically populated. Now, select the offer-ID from the drop-down list.

If you do not know your Offer-ID, then go back to your Azure portal. Click on “Subscriptions,” that should provide you the type of subscription that you have.

image3_1

 

Step 4: Click “Next”

image_4

 

Step 5: Click “Next”

image_5

Step 6: We are done with the registration with Cloudlyn. Cloudlyn needs about 2 hours for collecting the data.

image_6

 

If you find the content valuable, do consider sharing with your friends and colleagues.

Click here to download my PowerShell scripts for Free !!

Advertisements

AWS – Configure Point-To-Site in AWS envirnonment using OpenVPN

This document illustrates how we can create a VPN using the AMI – OpenVPN which is available in AWS MarketPlace.

Below shows the architecture that we would be able to achieve:

image1

We will set up an AWS VPC where we will launch our servers. One of the servers will be launched using the OpenVPN AMI. The other servers will be on public and private subnets within the VPC.

Steps to Achieve are as below:

Step 1: Login into AWS Console and choose VPC.

Step 2: Select Service – VPC

Step 3: Create a VPC. Provide the Name Tag and CIDR details. Also, create the subnet under this VPC.

image2

Step 4: Now, Let us go back to EC2 Service and then come back to VPC Later.

Step 5: In EC2 Service, Launch an EC2 Server and go to AWS Marketplace and choose the OpenVPN AMI. You can assign an elastic IP if necessary

image3

Step 6: Launch this instance with all the other necessary configuration. This AMI comes with default sec groups, keep them default and launch it. Note – This is not necessary to be launched in the VPC Created.

Step 7: Launch two more instance one with public IP and the other with private IP under the VPC created.

Step 8: Now let us go back to VPC. We will need to create Internet Gateway and RouteTable. Click on VPC in the console and go to Internet Gateway. Now click on Create Internet Gateway and provide a suitable Name tag. Attached this Gateway to the VPC we created earlier using the option “Attach to VPC”

image4

Step 9: Now, go to Route table and click on create route table. Update the Routes to have 0.0.0.0/0 (opens to the internet) and specify the IGW (internet gateway) which was created.

image5

Step 10: Update the Subnet Association to the

image6

Step 11: This completes the configuration on the AWS Services. Now we will need to configure the OpenVPN.

Step 12: SSH to the OpenVPN box using the username – openvpnas

Step 13: You will need to agree to the terms by typing “Yes”. Keep all the other setting default by just pushing the “Enter” button. By Default, the username will be “openvpn”. You will need to update the password using the command as per the below screenshot: sudo passwd openvpn.

image7_1

Step 14: Now go to the browser and type the IP address of the OpenVPN box. Ex: https://ipaddress

Step 15: Login in with the password updated earlier on the terminal.

image8

Step 16: Download the OpenVPN client as per the operating system. Install the client.

image9

Step 17: Click on the icon and select the OpenVPN server and click on connect. Once connected you will be able to connect to the servers within the vpc.

image10

Step 18: Now let us ping the Public IP and see the result.We were successful in pinging the Public Server under the VPC.

image11_1

Step 19: Now let us disconnect the OpenVPN and try to connect to the private server.

image12

Step 20: Now we see the ping requests are getting timed out. We are unable to reach the server using the private IP under the VPC.

image13_1

Step 21: Let us connect the VPN using the OpenVPN and try to ping the same Private Server.

image14_1

Looking for free PowerShell scripts? Check out my Powershell Contributions under Microsoft Technet Script Centre

Azure – PowerShell in Azure Cloud Shell

Today we are looking into PowerShell in Azure Cloud Shell. This is still in public preview as of this writing.

If you are wondering why Microsoft would introduce a PowerShell console inside the Azure Cloud Shell, then have a look at the below features:

Features

Browser-based shell experience

Cloud Shell enables access to a browser-based command-line experience built with Azure management tasks in mind. Leverage Cloud Shell to work untethered from a local machine in a way only the cloud can provide.

Choice of preferred shell experience

Azure Cloud Shell gives you the flexibility of choosing the shell experience that best suits the way you work. Linux users can opt for a Bash experience, while Windows users can opt for PowerShell.

Pre-configured Azure workstation

Cloud Shell comes pre-installed with popular command-line tools and language support so you can work faster.
View the full tooling list for Bash experience and PowerShell experience.

Automatic authentication

Cloud Shell securely authenticates automatically on each session for instant access to your resources through the Azure CLI 2.0.

Connect your Azure File storage

Cloud Shell machines are temporary and as a result, require an Azure file share to be mounted as clouddrive to persist your $Home directory. On the first launch, Cloud Shell prompts to create a resource group, storage account, and file share on your behalf. This is a one-time step and will be automatically attached for all sessions. A single file share can be mapped and will be used by both Bash and PowerShell in Cloud Shell.

Below are some conditions that we have to remember:

Cloud Shell runs on a temporary machine provided on a per-session, per-user basis
Cloud Shell times out after 20 minutes without interactive activity
Cloud Shell can only be accessed with a file share attached
Cloud Shell uses the same file share for both Bash and PowerShell
Cloud Shell is assigned one machine per user account
Permissions are set as a regular Linux user (Bash)

Now that we have some background knowledge on the PowerShell in Cloud Shell, let us dig more into the usage of it:

To access the Cloud Shell, click on the PowerShell icon in the Azure portal:

image_1

Once you click on the icon, a pane is opened at the bottom of the screen as shown below. You can choose from two options – BASH or PowerShell. Since we are interested in learning PowerShell in CloudShell, let us choose PowerShell as our desired option.

image_2

When you are starting for the first time, the Shell will configure an Azure File Storage. Cloud Shell machines are temporary and as a result, require an Azure file share to be mounted as clouddrive to persist your $Home directory. Alternatively, if you have multiple subscriptions, you will be allowed to choose your favorite subscription to work with.

image_3

Azure Authentication, Resource Group, Storage Account and File Storage are automatically created as shown below:

image_4

Testing an Azure command. Works perfectly.

image_5

If you are idle for more than 20 minutes, you will be kicked off the session, and you will have to start the session again:

image_6

Discovering the drives under PowerShell in Cloud Shell:

Now let us execute the Get-ChildItem cmdlet and see what we can find.

image_8

As we can see, running the Get-ChildItem in the current scope will list out the subscriptions that your account is associated with.

Traversing one step deeper into the directory, we can see the resources related to the subscription.

image_9

Let us get into the “StroageAccounts” directory to confirm if we get to see a list of Storage Accounts under the selected subscription:

image_10

PowerShell cmdlets to manage PowerShell in Cloud Shell:

From the below information, we can see that Microsoft provides us two cmdlets to work with the cloud shell.

image_12

Get-CloudDrive provides the details of the “Azure File Share” that was created when the cloud shell started. You may continue to use the cloud share. However, if you want a new one, you can dismount and create a new one using the Dismount-CloudDrive cmdlet.

image_11

Note: Once you dismount the Azure file share, your current session will be restarted to set up a new cloud share.

Assumption:

I am assuming that Microsoft is using container service infrastructure to provide a session. You will get the below windows path when you query for the temp drive:

C:\Users\ContainerAdministrator\AppData\Local\Temp

image_11

Note the administrator is a “ContainerAdministrator.” The container here could be a Windows Server or a Windows Container. I am assuming it is a Windows Container since the underlying “image” comes pre-packaged with below tools and a temporary one. A typical use case scenario for Container technology.

image_13

 

If the content is valuable to you, do consider sharing it with your friends and colleagues.

Did I miss out anything? Let me know in the comments section.

 

Download my PowerShell scripts for Free!

 

Azure – Copy data from Windows Virtual Machine to Azure Storage using AzCopy

AzCopy is a command-line utility designed for copying data from and to Microsoft Azure Blob, File and Table storage with optimal performance.

This WIKI will explain how to copy to and from Windows Virtual Machine to Azure blob storage. Download the latest AzCopy tool on Windows on your Virtual Machine

Below is the basic syntax of AzCopy:

AzCopy /Source:<source> /Dest:<destination> [Options]

Installing AzCopy on Windows Machine

1. Using the above link, once you have downloaded the AzCopy tool. The setup file will show as “MicrosoftAzureStorageTools”

download_azcopy

2. Double click on the “MicrosoftAzureStorageTools” installer and the set-up will continue. AzCopy will be installed in a default location – “C:\Program Files (x86)\Microsoft SDKs\Azure\”. You can change the default location, during the installation process.

3. Once the installation is done, you can find the “AzCopy.exe” under the installed folder. The default location is: “C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy” OR “%ProgramFiles%\Microsoft SDKs\Azure\AzCopy”. If desired, you can add the AzCopy installation location to your system path.

 azcopy_istalled

Upload Blobs To Azure Blob

Upload all blobs in a folder

Below is the syntax:

AzCopy /Source:C:\myfolder /Dest:https://myaccount.blob.core.windows.net/mycontainer /DestKey:key /S

Example:

I have created a folder called “CopyData” that has three empty text files. I will be uploading these three files to an Azure Blob container called “test-azcopy”

 folder_details

Now we will use AzCopy to copy this folder (recursively) to Azure Blob container

Command: .\AzCopy.exe /Source:C:\Users\manju\Desktop\CopyData /Dest:https://manjugtestdisks.blob.core.windows.net/test-azcopy /DestKey:<insert_storage_key> /S

(Note: I have removed my storage access key – for obvious reasons). “/S” parameter will recursively copy the folder and its sub folders.

 AzCopy_Finished

Now go back to the blob container to verify if the folder/files are copied. You may use any tool you want to do this. (Azure Portal, Azure Storage Explorer etc.,)

 copy_verify

We can upload single blob to Azure Blob. Below is the syntax:

Upload a single blob to a virtual directory

Syntax:

AzCopy /Source:C:\myfolder /Dest:https://myaccount.blob.core.windows.net/mycontainer/vd /DestKey:key /Pattern:abc.txt

Upload a single blob
Syntax:

AzCopy /Source:C:\myfolder /Dest:https://myaccount.blob.core.windows.net/mycontainer /DestKey:key /Pattern:”abc.txt”

Download Blobs from Azure Blob Storage

Download all blobs from a container

Below is the syntax:

AzCopy /Source:https://myaccount.blob.core.windows.net/mycontainer /Dest:C:\myfolder /SourceKey:key /S

Example:

Earlier we had uploaded files from a local folder – “CopyData” to Azure Blob container “test-azcopy”. Now we shall download the same three files to a local folder called “DownloadData”.

Command:

.\AzCopy.exe /Source:https://manjugtestdisks.blob.core.windows.net/test-azcopy /Dest:C:\Users\manju\Desktop\DownloadData /SourceKey:<insert_storage_access_key> /S

 download_data

Similarly, we can download single blobs, below is the syntax

Download a single blob
Syntax:

AzCopy /Source:https://myaccount.blob.core.windows.net/mycontainer /Dest:C:\myfolder /SourceKey:key /Pattern:”abc.txt”

Download a single blob from the secondary region

Syntax:
AzCopy /Source:https://myaccount-secondary.blob.core.windows.net/mynewcontainer /Dest:C:\myfolder /SourceKey:key /Pattern:abc.txt

Download blobs with a specific prefix

Syntax:
AzCopy /Source:https://myaccount.blob.core.windows.net/mycontainer /Dest:C:\myfolder /SourceKey:key /Pattern:a /S

Copy blobs in Blob storage

Copy a single blob from one container to another within the same storage account

Syntax:
AzCopy /Source:https://myaccount.blob.core.windows.net/mycontainer1 /Dest:https://myaccount.blob.core.windows.net/mycontainer2 /SourceKey:key /DestKey:key /Pattern:abc.txt

Copy a single blob from one storage account to another

Syntax:
AzCopy /Source:https://sourceaccount.blob.core.windows.net/mycontainer1 /Dest:https://destaccount.blob.core.windows.net/mycontainer2 /SourceKey:key1 /DestKey:key2 /Pattern:abc.txt

Copy a single blob from the secondary region to the primary region

Syntax:
AzCopy /Source:https://myaccount1-secondary.blob.core.windows.net/mynewcontainer1 /Dest:https://myaccount2.blob.core.windows.net/mynewcontainer2 /SourceKey:key1 /DestKey:key2 /Pattern:abc.txt

Copy a single blob and its snapshots from one storage account to another

Syntax:
AzCopy /Source:https://sourceaccount.blob.core.windows.net/mycontainer1 /Dest:https://destaccount.blob.core.windows.net/mycontainer2 /SourceKey:key1 /DestKey:key2 /Pattern:abc.txt /Snapshot

Copy all blobs in a container to another storage account

Syntax:
AzCopy /Source:https://sourceaccount.blob.core.windows.net/mycontainer1 /Dest:https://destaccount.blob.core.windows.net/mycontainer2 /SourceKey:key1 /DestKey:key2 /S

Download files from File storage

Download a single file
Syntax:
AzCopy /Source:https://myaccount.file.core.windows.net/myfileshare/myfolder1/ /Dest:C:\myfolder /SourceKey:key /Pattern:abc.txt

Download all files in a directory
Syntax:
AzCopy /Source:https://myaccount.file.core.windows.net/myfileshare/ /Dest:C:\myfolder /SourceKey:key /S

Upload Files to File storage

Upload a single file
Syntax:
AzCopy /Source:C:\myfolder /Dest:https://myaccount.file.core.windows.net/myfileshare/ /DestKey:key /Pattern:abc.txt

Upload all files in a folder
Syntax:
AzCopy /Source:C:\myfolder /Dest:https://myaccount.file.core.windows.net/myfileshare/ /DestKey:key /S

Upload files matching a specific pattern
Syntax:
AzCopy /Source:C:\myfolder /Dest:https://myaccount.file.core.windows.net/myfileshare/ /DestKey:key /Pattern:ab* /S

Copy files in File storage

Copy from one file share to another
Syntax:
AzCopy /Source:https://myaccount1.file.core.windows.net/myfileshare1/ /Dest:https://myaccount2.file.core.windows.net/myfileshare2/ /SourceKey:key1 /DestKey:key2 /S

Copy from an Azure File share to Blob storage
Syntax:
AzCopy /Source:https://myaccount1.file.core.windows.net/myfileshare/ /Dest:https://myaccount2.blob.core.windows.net/mycontainer/ /SourceKey:key1 /DestKey:key2 /S

Copy a blob from Blob storage to an Azure File share
Syntax:
AzCopy /Source:https://myaccount1.blob.core.windows.net/mycontainer/ /Dest:https://myaccount2.file.core.windows.net/myfileshare/ /SourceKey:key1 /DestKey:key2 /S

Synchronously copy files
Syntax:
AzCopy /Source:https://myaccount1.file.core.windows.net/myfileshare1/ /Dest:https://myaccount2.file.core.windows.net/myfileshare2/ /SourceKey:key1 /DestKey:key2 /S /SyncCopy

Export data from Table storage

Export a table
Syntax:
AzCopy /Source:https://myaccount.table.core.windows.net/myTable/ /Dest:C:\myfolder\ /SourceKey:key

Split an export from Table storage into multiple files
Syntax:
AzCopy /Source:https://myaccount.table.core.windows.net/mytable/ /Dest:C:\myfolder /SourceKey:key /S /SplitSize:100

Import data into Table storage

Import a table
Syntax:
AzCopy /Source:C:\myfolder\ /Dest:https://myaccount.table.core.windows.net/mytable1/ /DestKey:key /Manifest:”myaccount_mytable_20140103T112020.manifest” /EntityOperation:InsertOrReplace

Check out my Powershell Contributions to Microsoft Technet Script Centre

Azure – First look into “Event Grid Subscriptions”

This blog takes a first look at the “Event Grid” service by Azure. Microsoft announced this service in August 2017. This is still in public preview as of writing this blog.

Azure Event Grid allows you to easily build applications with event-based architectures. You select the Azure resource you would like to subscribe to and give the event handler or WebHook endpoint to send the event to. Event Grid has built-in support for events coming from Azure services, like storage blobs and resource groups. Event Grid also has custom support for application and third-party events, using custom topics and custom webhooks.

You can use filters to route specific events to different endpoints, multicast to multiple endpoints, and make sure your events are reliably delivered. Event Grid also has built in support for custom and third-party events.

event-grid-functional-model

We shall create a simple “Event Grid Subscription” which comes under Event Grid. This Event Subscription will monitor one of Azure Resource Group for events. Trigger an Azure automation runbook, in case if any event occurs on the resource group.

Below is the event types that the event subscription will monitor:

RG_Event_Types.jpg

  1. Search for the “Event Subscription”search_event_subscription
  2. Fill in the required details and click on CREATE. Enter your Azure Automation Runbook’s webhook under the “Subscriber Endpoint”. Thus, your runbook will be triggered when ever any event under the specified runbook occurs.create_event_sub
  3. Once the “Event Subscription” is created. Create a simple resource (like public IP), and we can see that our runbook is triggered. [Open JOBS pane under the runbook to verify that the runbook has run]trigger_runbook

 

Follow this link, if you are looking for Azure APIs to create Event Subscriptions.

Follow this link for more information about Azure Event Grid.

 

Looking for free PowerShell scripts? Check out my Powershell Contributions under Microsoft Technet Script Centre

Windows – Convert windows partition from GPT to RAW

This blog will teach you how to convert a “GPT” partition to “RAW” using Windows Command Prompt.

  1. Bring up the windows disk partition tool
    C:\Users\manju>diskpart
  2. List the existing disks
    DISKPART> list disk
  3. Select the disk that you want to change to “RAW” type
    DISKPART> select disk 3
  4. Now type “clean” to convert any partition (GPT in this example) to “RAW”
    DISKPART> clean
  5. Verify by listing the disks
    DISKPART> list disk

 

Screenshot:

convert_GPT_2_RAW

Powershell – SQL Server pre configuration

This script can be used as a pre-configuration script in case if you want to attach a disk and partition it. Later use the partition as SQL Data and Log folder.

Below is the script flow:

1. Creates a log file in C:\temp folder for logging purpose.

2. Checks for the attached disks and checks for RAW partition.

3. Initializes the RAW to GPT.

4. Creates two partitions of equal size, format them to NTFS with drive letters ‘R’ and ‘S’. (Different drive letters can be provided by changing the appropriate variables)

5. Configure the SQL Server, to use, ‘R’ and ‘S’ as Data and Log directory respectively.

6. Validate the SQL Server service status.

Note: Tested and validated on SQL Server 2012

Download the Powershell script: SQL Server pre configuration

Screenshots:

 

R_and_S_folder

 

temp_data_log_folders

 

database_config