Giter VIP home page Giter VIP logo

azure-lighthouse-samples's Issues

Create-AzDiagPolicy.ps1 fails for resourceType Microsoft.NetApp/netAppAccounts/capacityPools/volumes (and potentially others)

Description

In the Parse-ResourceType function found in the Create-AzDiagPolicy.ps1 script there are currently checks for 1 or 2 / characters, but not 3.

Block in question:

    if($ResourceType.Split("/").count -eq 3)
    {
        $nameField = "fullName"
        $DirectoryNameBase = "Apply-Diag-Settings-$sinkDest-" + $($resourceType.Split("/", 3))[0] + "-" + $($resourceType.Split("/", 3))[1] + "-" + $($resourceType.Split("/", 3))[2] + $KindDirVar
    }
    if($ResourceType.Split("/").count -eq 2)
    {
        $nameField = "name"
        $DirectoryNameBase = "Apply-Diag-Settings-$sinkDest-" + $($resourceType.Split("/", 2))[0] + "-" + $($resourceType.Split("/", 2))[1] + $KindDirVar
    }

Command Ran

.\Create-AzDiagPolicy.ps1 -ExportLA -ValidateJSON -ManagementGroup -ManagementGroupID <management_group_id> -ExportAll -ExportDir policies -AllRegions

Error

Update-LogAnalyticsJSON : Cannot bind argument to parameter 'nameField' because it is an empty string.
At C:\Users\<user>\Documents\WindowsPowerShell\Scripts\Create-AzDiagPolicy.ps1:2376 char:153
+ ... rray $metricsArray -logsArray $logsArray -nameField $RPVar[1] -kind $ ...
+                                                         ~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Update-LogAnalyticsJSON], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Update-LogAnalyticsJSON

Expected Behavior

Diagnostic Policy JSON is generated for Microsoft.NetApp/netAppAccounts/capacityPools/volumes

ClassicAdministratorListFailed

Hi There,

I'm trying to deploy the ARM template "delegatedResourceManagement" to a customers subscription.

The account being used to deploy has Contributor permission to the subscription I'd like to deploy into.

My subscription is provided via a CSP (Cloud Service Provider)

I have found that on the Access Control page of the subscription, under the "Classic Administrators" section that there is the following advisory message:
"This type of subscription does not support classic administrators."

There are no classic administrators listed.

Please see the full error below:
New-AzDeployment : 8:12:23 PM - Resource Microsoft.ManagedServices/registrationDefinitions 'c62a69fe-8c56-57fc-8f1a-8be43d413609' failed with message '{
"error": {
"code": "ClassicAdministratorListFailed",
"message": "Failed to list classic administrators of subscription 'dec6084b-c0eb-43d3-95e2-8a07f1bd2c68': 'The subscription ID was not found.'."
}
}'

Is this template dependent on being classic administrator supported?
Is there any workaround to this issues?

Please let me know if you would like me to provide any additional information and I would be more than happy to provide.

image

image

API not retrieving tenant actions

What happened with the API to get the tenant-level registration and unregistration data?

The specific user querying the API can get see the directory data within the Azure Portal, but loading either the API for:

"https://management.azure.com/providers/microsoft.insights/eventtypes/management/values?api-version=2015-04-01&`$filter=eventTimestamp ge '$($dateFormatForQuery)'"

, or the query that the Azure Portal is using:

https://management.azure.com/providers/microsoft.insights/eventtypes/management/values?api-version=2015-04-01&1$filter=eventTimestamp ge '$($dateFormatForQuery)' and eventTimestamp le '$($dateFormatForQueryHigher)'and eventChannels eq 'Admin, Operation' and resourceProvider eq 'Microsoft.Resources'

Return information, but NOT the specific registration and unregistration data.

Is this expected?

Can't Deploy Sample AZ Policy Template in Azure Portal

When I Copy and Paste this sample policy template into the Azure Portal as a new Policy Definition I get an error message.

Here is the template:
https://github.com/Azure/Azure-Lighthouse-samples/blob/master/templates/policy-add-or-replace-tag/addOrReplaceTag.json

Error Message:
Creating policy definition 'TEST' in 'Training' failed. The request content was invalid and could not be deserialized: 'Required property 'policyRule' expects a value but got null. Path 'properties', line 1, position 168.'.

I've tried a few other sample policies from github and received similar error messages.

Both Sample documents from this Microsoft Document article I'm not able to deploy as well.
https://docs.microsoft.com/en-us/azure/lighthouse/how-to/deploy-policy-remediation#create-a-user-who-can-assign-roles-to-a-managed-identity-in-the-customer-tenant

Please tell me what I missing.
Thank you!

How to compare authorizations array

At present once the policy is deployed, any changes in the authorisations in the parameters will not make the policy non-compliant as the policy rule only checks for managedByTenantId

I can use the Microsoft.ManagedServices/registrationDefinitions/authorizations[] to compare the length of the existing authorizations with managedByAuthorizations parameter value and Microsoft.ManagedServices/registrationDefinitions/authorizations[].roleDefinitionId for roleDefinitionIds of the authorizations, however I am not able to use / find aliases to compare all the values in the authorizations array in policy rule
Attached is what works so far.

Is there a way to do that that I am not aware of?

Screenshot 2021-11-03 at 12 03 47

Incorrect template delegatedResourceManagement.json

I think the sample template "Azure-Delegated-Resource-Management/templates/delegated-resource-management/delegatedResourceManagement.json" makes use of an inexistent parameter "mspName". Al least the deployment failed for me as it is, and it worked when I added the parameter...
In fact, I used a subscriptionName parameter instead, to be consistent with the sample templates for resource groups (but I'm not sure if this was the intent, or if this value finally shows up somewhere)

Error deploying rgDelegatedResourceManagement (Code: InvalidRegistrationDefinitionUri)

I'm trying to deploy rgDelegatedResourceManagement using the supplied template and parameter files.

Powershell command:

New-AzResourceGroupDeployment -ResourceGroupName LighthouseTest -TemplateFile .\rgDelegatedResourceManagement.json -TemplateParameterFile .\rgDelegatedResourceManagement.parameters.json

Raw error:
(Subscription id in error is masked by me but matches the target subscription for the deployment)

{
"code": "DeploymentFailed",
"message": "At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.",
"details": [
{
"code": "BadRequest",
"message": "{\r\n "error": {\r\n "code": "InvalidRegistrationDefinitionUri",\r\n "message": "The registration definition request scope '/subscriptions/99999999-9999-9999-9999-999999999999/resourcegroups/LighthouseTest' should be '/subscriptions/<subscriptionId>'."\r\n }\r\n}"
}
]
}

Parameter file:
(Tenant id and principal id are masked by me below but match the Azure AD tenant id and security group ids for the Azure AD and security group which is requesting delegated permissions)

{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"mspName": {
"value": "Breakpoint Technology"
},
"rgName": {
"value": "LighthouseTest"
},
"mspOfferDescription": {
"value": "Breakpoint Technology - AI Analysis"
},
"managedByTenantId": {
"value": "11111111-1111-1111-1111-111111111111"
},
"authorizations": {
"value": [
{
"principalId": "22222222-2222-2222-2222-222222222222",
"principalIdDisplayName": "Lighthouse Test",
"roleDefinitionId": "73c42c96-874c-492b-b04d-ab87d138a893"
}
]
}
}
}

I have confirmed the target subscription has the Microsoft.ManagedServices provider registered.

Error when deploying deploy-azure-mgmt-services/rgWithAzureMgmt

Trying to deploy rgWithAzureMgmt, I get the following error:
400 Client Error: Bad Request for url: https://management.azure.com/subscriptions/...

I am deploying from azcli using:
az deployment create --subscription --name ASCDeployment2 --template-file .\rgWithAzureMgmt.json --location eastus --verbose

I have tried it specifying --parameters using either one of the two files as well...

Let me know if I can provide more information!

Thanks,
Dave

Register Managed Services RP Partner error AADSTS500113

The issue:
Adding the registered app from step 1 to the customer tenants in step 2 fails due to no reply address.

What I tried:
I tried adding https://<functionName>.azurewebsites.net/.auth/login/aad/callback as the callback but this resulted in a different error, a 404 error.

I created a registered app to use as the service principal described in step 1.
Step 2 describes adding that registered app to the customer tenants using this pattern: https://login.microsoftonline.com/{tenant-id}/adminconsent?client_id={client-id}.
Navigating to the built URL resulted in a failure to sign in and returned an AADSTS500113 error stating that there's no reply address registered for the application.

Since we're using the registered app for the service principal and it's not a real web application, what reply address should we use in the registered app?

Deployment of Management Group level policy for Lighthouse fails

Then trying to deploy the policy to delegate subscriptions at management group level I get the following error:

New-AzManagementGroupDeployment -Name onboard-lighthouse -Location westeurope -ManagementGroupId core-mgr -TemplateFile .\deployLighthouseIfNotExistManagementGroup.json -TemplateParameterFile .\deployLighthouseIfNotExistsManagementGroup.parameters.json -Verbose
VERBOSE: 
VERBOSE: 10:49:49 AM - Template is valid.
VERBOSE: 10:49:50 AM - Create template deployment 'onboard-lighthouse'
VERBOSE: 10:49:50 AM - Checking deployment status in 5 seconds
New-AzManagementGroupDeployment : 10:49:55 AM - The deployment 'onboard-lighthouse' failed with error(s). Showing 1 out of 1 error(s).
Status Message: The policy definition 'Enable-Azure-Lighthouse' rule is invalid. The 'field' property 'Microsoft.ManagedServices/registrationAssignments/registrationDefinitionProperties.managedByTenantId' of the policy rule doesn't exist as an alias under provider 'Microsoft.ManagedServices' and resource     
type 'registrationAssignments'. The supported aliases are 'Microsoft.ManagedServices/registrationAssignments/registrationDefinitionId; Microsoft.ManagedServices/registrationAssignments/provisioningState; Microsoft.ManagedServices/registrationAssignments/registrationDefinition.description; 
Microsoft.ManagedServices/registrationAssignments/registrationDefinition.authorizations[*].principalId; Microsoft.ManagedServices/registrationAssignments/registrationDefinition.authorizations[*].roleDefinitionId; Microsoft.ManagedServices/registrationAssignments/registrationDefinition.authorizations[*];      
Microsoft.ManagedServices/registrationAssignments/registrationDefinition.authorizations; Microsoft.ManagedServices/registrationAssignments/registrationDefinition.registrationDefinitionName; Microsoft.ManagedServices/registrationAssignments/registrationDefinition.provisioningState; 
Microsoft.ManagedServices/registrationAssignments/registrationDefinition.manageeTenantId; Microsoft.ManagedServices/registrationAssignments/registrationDefinition.manageeTenantName; Microsoft.ManagedServices/registrationAssignments/registrationDefinition.managedByTenantId; 
Microsoft.ManagedServices/registrationAssignments/registrationDefinition.managedByTenantName; Microsoft.ManagedServices/registrationAssignments/registrationDefinition.plan.name; Microsoft.ManagedServices/registrationAssignments/registrationDefinition.plan.publisher; 
Microsoft.ManagedServices/registrationAssignments/registrationDefinition.plan.product; Microsoft.ManagedServices/registrationAssignments/registrationDefinition.plan.version; Microsoft.ManagedServices/registrationAssignments/registrationDefinition.plan; 
Microsoft.ManagedServices/registrationAssignments/registrationDefinition.id; Microsoft.ManagedServices/registrationAssignments/registrationDefinition.type; Microsoft.ManagedServices/registrationAssignments/registrationDefinition.name; 
Microsoft.ManagedServices/registrationAssignments/registrationDefinition'. Please open a CSS ticket at https://azure.microsoft.com/support/create-ticket to request new aliases. (Code:InvalidPolicyAlias)
CorrelationId: ae50a5dd-7463-4476-b30e-1093f451a0ae
At line:1 char:1
+ New-AzManagementGroupDeployment -Name onboard-lighthouse -Location we ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-AzManagementGroupDeployment], Exception
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureManagementGroupDeploymentCmdlet

I fixed the error by changing:

"existenceCondition": {
    "allOf": [
        {
            "field": "type",
            "equals": "Microsoft.ManagedServices/registrationDefinitions"
        },
        {
            "field": "Microsoft.ManagedServices/registrationAssignments/registrationDefinitionProperties.managedByTenantId",
            "equals": "[[parameters('managedByTenantId')]"
        }
    ]
},

to:

"existenceCondition": {
    "allOf": [
        {
            "field": "type",
            "equals": "Microsoft.ManagedServices/registrationDefinitions"
        },
        {
            "field": "Microsoft.ManagedServices/registrationAssignments/registrationDefinition.managedByTenantId",
            "equals": "[[parameters('managedByTenantId')]"
        }
    ]
},

Template file to onboard subscription is invalid

The template defined here: https://github.com/Azure/Azure-Lighthouse-samples/blob/master/templates/delegated-resource-management/delegatedResourceManagement.json to onboard subscriptions has an extra field in the template outputs section, called delegatedRoleDefinitionIds. Presence of this field makes the template invalid, and the template cannot be deployed.

This incorrect field is removed, and the template is found to be valid and the deployment succeeds. The PR for the change is here: #80

image

The raw error is given below:
{
"deploymentStatusCode": -1,
"stage": 6,
"expected": true,
"error": {
"message": "Deployment template parse failed: 'Could not find member 'delegatedRoleDefinitionIds' on object of type 'TemplateOutputParameter'. Path 'outputs.authorizations.delegatedRoleDefinitionIds', line 82, position 42.'."
},
"subscriptionId": "cb729363-8115-4333-ac0f-99e4b64d2634",
"location": "eastus",
"deploymentName": "Microsoft.Template-20200901215323",
"details": {
"code": "InvalidTemplate",
"message": "Deployment template parse failed: 'Could not find member 'delegatedRoleDefinitionIds' on object of type 'TemplateOutputParameter'. Path 'outputs.authorizations.delegatedRoleDefinitionIds', line 82, position 42.'.",
"additionalInfo": [
{
"type": "TemplateViolation",
"info": {
"lineNumber": 0,
"linePosition": 0,
"path": ""
}
}
]
}
}

Create-AzDiagPolicy.ps1 can't set diagnostic settings on subresources of StorageAccount

It seems Microsoft has allowed setting diagnostic settings on subresoruces of StorageAccounts, eg. Blobs. This is where transaction logging is enabled.

The script at the moment doesn't seem to pick these up and as such can't automatically deploy Diagnostic settings for these.

Are there any intentions on supporting Blobs, File shares etc from Storage Accounts in the Create-AzDiagPolicy.ps1 script

whether "authorization" parameter in the ARM template is necessary or not

Hi all,

I tried to use the following template to assign authorizations to the roles.
https://github.com/Azure/Azure-Lighthouse-samples/blob/master/templates/delegated-resource-management-eligible-authorizations/rg/rg.parameters.json
I do not want to have the permanent role assignments for any principle and I only want to assign the PIM for principles.

I tried to delete "authorization" parameters both in the ARM template and parameter file. I only kept and configured the "eligibleAuthorizations" part which set up the PIM values. I deployed this ARM template and the following error came out.

{
"code": "DeploymentFailed",
"message": "At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.",
"details": [
{
"code": "InvalidTemplate",
"message": "Unable to process template language expressions for resource '/subscriptions/xxxx/providers/Microsoft.ManagedServices/registrationDefinitions/xxxxx' at line '71' and column '9'. 'The template parameter 'authorizations' is not found. Please see https://aka.ms/arm-template/#parameters for usage details.'"
}
]
}

May I ask whether this "authorization" is required and the necessary reason? Is it possible to only use the PIM in this template?

Thanks in advance!

Classic roles (e.g. service administrator) project all resource groups

If a Lighthouse definition is assigned one or more resource groups, then only those selected resource groups should be projected. (This is an ARM RBAC mechanism with defined authorisations and selected assignment scopes.)

However if there is a classic ASM role then all resource groups are projected. This will be different to what the customer expected to happen based on the delegations they see in the Service Providers blade.

Recommend that the Lighthouse projection only respects the ARM RBAC authorisations and scope points.

Add Get-AzDelegatedSubscription to lighthouse-demo

Suggestion: The demo would work better (personal opinion) when you include the function as you build here: https://github.com/Azure/Azure-Lighthouse-samples/blob/master/Azure-Delegated-Resource-Management/tools/get-azdelegatedsubscription/Get-AzDelegatedSubscription.ps1

As the demo script here: https://github.com/Azure/Azure-Lighthouse-samples/tree/master/Azure-Delegated-Resource-Management/tools/lighthouse-demo will run on all subscriptions that one would have access too ($subs = get-azsubscription), not just the ones added through delegated resource management.

Just an idea :) but awesome examples!

Automatic remediation (onboarding)

Hi,

during creation of the policy i created a system assigned managed identity for remediation.
When i create a remediation task manually of non-compliant subscriptions, everything works fine.

However, am i getting it right that auto-remediation does not work for subscriptions which have been created before the policy was created?

Thanks in advance!

rg-delegated-resource-management - Give customer a dropdown list.

Is there a way to edit the template so that the customer can select a Resource Group from a dropdown list when deploying in Azure portal?
I am Attempting to use a deploy to Azure button, when the link is used by the customer the Resource Group field lokks like:
[{"rgName":"test"},{"rgName":"test2"},{"rgName":"test3"}]****

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.