Git Product home page Git Product logo

Comments (4)

anton-evseev avatar anton-evseev commented on August 29, 2024 1

@MiYanni sounds good

from azure-powershell-common.

MiYanni avatar MiYanni commented on August 29, 2024

@number213 I also just checked. That function, Normalize-Location, is only called in that single test you mentioned. I'd opt to just remove it if it is causing confusion.

Instead, you can do this for your test:

$location.ToLower() -replace '[^a-z0-9]'

Since Get-Location is used for testing, if the service returns westus when the test expects West US, that should be flagged as a failure. We don't want to change it to hide potential issues. Basically, Get-Location is unaware of what format, Name or DisplayName, is being used for the location.

However, I do agree that there could be an improvement here. Also, I didn't even know we had a location cmdlet until I just found this: http://www.sqlservercentral.com/blogs/bradleyschacht/2018/05/22/azure-powershell-list-data-center-locations/

from azure-powershell-common.

anton-evseev avatar anton-evseev commented on August 29, 2024

Basically, Get-Location is unaware of what format, Name or DisplayName, is being used for the location.

Is it possible for Get-Location to remember what format prefferedLocation is, do agnostic search and return location in the same format the user passed it? Something like

    param([string]$providerNamespace, [string]$resourceType, [string]$preferredLocation)
    $isDisplayName = $preferredLocation.IndexOf(" ") -ne -1;

    # ...

    $location = $resourceTypes.Locations | Where-Object { (Normalize-Location $_) -eq (Normalize-Location $preferredLocation) }
    if ($location -eq $null)
    {
        # ...
    }
    elseif($isDisplayName)
    {

        return $location
    }
    else
    {
        return $location.ToLower() -replace '[^a-z0-9]'
    }

That's my concert, Get-Location doesn't work with Name format

PS C:\Users\v-anevse> Get-Location "Microsoft.Network" "ExpressRouteCircuits" "centraluseuap"
East US
PS C:\Users\v-anevse> Get-Location "Microsoft.Network" "ExpressRouteCircuits" "Central US EUAP"
Central US EUAP

from azure-powershell-common.

MiYanni avatar MiYanni commented on August 29, 2024

@number213 I'd rather add a switch paramter to Get-Location, such as -UseCanonical, which you specify when you want the all lowercase, no spaces version of the location. So, using your example:

PS C:\Users\v-anevse> Get-Location "Microsoft.Network" "ExpressRouteCircuits" "centraluseuap" -UseCanonical
centraluseuap
PS C:\Users\v-anevse> Get-Location "Microsoft.Network" "ExpressRouteCircuits" "Central US EUAP"
Central US EUAP

That way, current implementations are not broken/changed. And, you can get the functionality you want (explicitly) out of it. How does that sound?

from azure-powershell-common.

Related Issues (11)

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.