Git Product home page Git Product logo

azure_task_7_work_with_objects_in_powershell's Introduction

Work with objects in Powershell

What a life! You sent the cost estimates to your investors, and they were not very happy about the numbers. Investors are planning for the application growth, with more users you will need more VMs, and with more VMs, the cost of one VM will make a bigger impact on the total bill for the cloud infrastructure. They said to you that they invest in your startup if you find a way to cut costs twice for a single VM. After some research, you found this new ARM-based VM size famiily which might do the trick, but it is not available in all regions yet. So in this task, you will need to write a script, which will help you to find regions, where the VM size you need is available.

Prerequisites

Before completing any task in the module, make sure that you followed all the steps described in the Environment Setup topic, in particular:

  1. Ensure you have an Azure account and subscription.

  2. Install PowerShell 7 on your computer. All tasks in this module use Powershell 7. To run it in the terminal, execute the following command:

    pwsh
    
  3. Install Azure module for PowerShell 7:

    Install-Module -Name Az -Repository PSGallery -Force
    

If you are a Windows user, before running this command, please also run the following: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

  1. Log in to your Azure account using PowerShell:
    Connect-AzAccount -TenantId <your Microsoft Entra ID tenant id>
    

Requirements

In this task, you will need to write a Powershell script, which looks for regions, where particular VM size (Standard_B2pts_v2) is available for use:

  • Write a Powershell script, which implements task requirements in the file task.ps1 in this repo.

  • Folder data in this repository contains a set of JSON files. Each file is named after Azure region, and contains a list of VM sizes, available in the region.

  • Script should loop through the files. In each file, script should convert data from JSON to a list of objects, and search for the object, which represents VM size Standard_B2pts_v2. If such object was found - the region name should be added to the result list of regions.

  • Result list of regions should be exported by script in JSON format to file result.json in this repository. Here how the file should look like:

        [
            "australiaeast",
            "canadacentral",
            ...
            "westus3"
        ]
    
  • After testing the script locally, make sure that the result.json is not commited to the repository (othervise validation will fail), and submit the solution for a review.

Hints

  • Use Get-ChildItem to get a list of files in the data directory. Feel free to explore the properties of the returned objects - they have separate properties for the full file path (suitable for the Get-Content comand) and for the file name (handy if you just need the file name).

  • You can get a region name by cutting a suffix '.json' from the file name. In Powershell, you can cut a substring from sting just by using 'Replace()' method of the string variable or property. It's easy, just try it:

        $stringVariable = "filename.json"
        $stringVariable = $stringVariable.Replace('.json', '')
        Write-Host $stringVariable
    

azure_task_7_work_with_objects_in_powershell's People

Watchers

 avatar  avatar  avatar  avatar

Forkers

pavlosoletskyy

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.