Git Product home page Git Product logo

azureblueprint's People

Contributors

deadpoolheartsrr avatar jimgbritt avatar oechiih avatar oxhobbs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

azureblueprint's Issues

Add a name length check when using the filename to name an assignment.

Context :
When an assignment has no name, the script use the filename to generate the assignment name.
Then the name is used to generate the assignment ID.

Issue :
If the name exceeds a maximum length of 48, the API returns a (400) Bad Request.
The script does not provide details about the issue.

Suggested fix :
Add a control and raise an error when using a filename longer than 48 characters.
Display more details about the API errors. In this case, the API returns an explicit error message we could display :

"error": {
        "code": "InvalidResourceName",
        "message": "The resource name 'policyAssignmentAF_ResourcesGroup_AuditMandatoryTags' exceeds the maximum length of 48."
    }

Have a Blueprint Mode Management Group or Subscription

Context:

  • The Blueprint has been created at a subscription level, not Management Group/Subscription level.
  • The Blueprint cannot be exported using Manage-AzureRMBlueprint

I had created Blueprints at the Subscription level only. Could not export using the current version of Manage-AzureRMBlueprint

I modified your script with the following:
1. New Parameter

# Blueprint Mode (Subscription or ManagementGroup)
[Parameter(ParameterSetName='Export')]
[ValidateSet("ManagementGroup","Subscription")]
[string]$BlueprintMode='ManagementGroup',`

2. Listing Management Groups

if(!($ManagementGroupID) **-and $BlueprintMode -eq "ManagementGroup")
{
    if($ModuleMode -eq "AzureRM"){[array]$MgtGroupArray = Add-IndexNumberToArray (Get-AzureRmManagementGroup)}
    if($ModuleMode -eq "Az"){[array]$MgtGroupArray = Add-IndexNumberToArray (Get-AzManagementGroup)}
    if(!$MgtGroupArray)
....

3. Get All Blueprints

# Get all Blueprints
if ($BlueprintMode -eq "Subscription")
{
    $BlueprintsURI = "https://management.azure.com/subscriptions/$($SubscriptionID)/providers/Microsoft.Blueprint/blueprints?api-version=$($APIVersion)"
} else {
    $BlueprintsURI = "https://management.azure.com/providers/Microsoft.Management/managementGroups/$($ManagementGroupID)/providers/Microsoft.Blueprint/blueprints?api-version=$($APIVersion)"
}

4. No Blueprints found

if ($BlueprintMode -eq "Subscription")
{
    write-host "No Blueprints found in $SubscriptionID"
} else
{
    write-host "No Blueprints found in $ManagementGroupID"
}

5. Select a Blueprint

if ($BlueprintMode -eq "Subscription")
{
    $BPsArray | Select-Object "#", @{Label = "Blueprint Name";Expression={$_.name}}, @{Label = "Subscription"; Expression = {$($BPsArray.ID).split("/")[2]}}, @{Label = "Blueprint Description";Expression={$_.properties.description}} | ft
} else 
{
    $BPsArray | Select-Object "#", @{Label = "Blueprint Name";Expression={$_.name}}, @{Label = "ManagementGroup"; Expression = {$($BPsArray.ID).split("/")[4]}}, @{Label = "Blueprint Description";Expression={$_.properties.description}} | ft
}

6. Blueprint and Artifacts URI

if ($BlueprintMode -eq "Subscription")
{
    $BluePrintURI = "https://management.azure.com/subscriptions/$($SubscriptionID)/providers/Microsoft.Blueprint/blueprints/$($BluePrintName)?api-version=$($APIVersion)"
    $ArtifactsURI = "https://management.azure.com/subscriptions/$($SubscriptionID)/providers/Microsoft.Blueprint/blueprints/$($BluePrintName)/artifacts?api-version=$($APIVersion)"
} else
{
    $BluePrintURI = "https://management.azure.com/providers/Microsoft.Management/managementGroups/$($ManagementGroupID)/providers/Microsoft.Blueprint/blueprints/$($BluePrintName)?api-version=$($APIVersion)"
    $ArtifactsURI = "https://management.azure.com/providers/Microsoft.Management/managementGroups/$($ManagementGroupID)/providers/Microsoft.Blueprint/blueprints/$($BluePrintName)/artifacts?api-version=$($APIVersion)"
}

Thanks!

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.