Code Monkey home page Code Monkey logo

azure-ad-conditional-access-apis's Introduction

languages page_type description products
rest
powershell
sample
Use Conditional Access Graph APIs to manage policies like code. Automate approvals to promote policies from preproduction environments, backup and restore, monitor change, and plan ahead for emergencies.
azure
azure-active-directory

Manage Conditional Access policies like code

Many organizations have expressed their need to manage as much of their environments like code as possible. Using Microsoft Graph you can treat Conditional Access policies like any other piece of code in your environment.

Microsoft Graph provides a unified programmability model that organizations can use to interact with data in Microsoft 365, Windows 10, and Enterprise Mobility + Security. For more information about Microsoft Graph, see the article, Overview of Microsoft Graph.

An image showing the primary resources and relationships that are part of the graph

The following examples are provided as is with no support. You can use these examples as a basis for tooling in your organization.

Many of the following examples use tools like Managed Identities, Logic Apps, OneDrive, Teams, and Azure Key Vault.

Configure

PowerShell

For many administrators, PowerShell is already an understood scripting tool. The following example shows how to use the Azure AD PowerShell module to manage Conditional Access policies.

Graph API

This example shows the basic Create, Read, Update, and Delete (CRUD) options available in the Conditional Access Graph APIs. The example also includes some JSON templates you can use to create some sample policies.

Configure using templates

Use Conditional Access APIs to deploy Conditional Access policies in your pre-production environment using a template.

Test

This example models safer deployment practices with approval workflows that can copy Conditional Access policies from one environment, like pre-production, to another, like your production environment.

Deploy

This example provides a mechanism to perform a staged deployment Conditional Access policies gradually to your user population, allowing you to manage support impact and spot issues early.

Monitor

This example provides a mechanism to monitor Conditional Access policy changes over time and can trigger alerts when key policies are changed.

Manage

Backup and restore

Automate the backup and restoration of Conditional Access policies with approvals in Teams using this example.

Emergency access accounts

Multiple administrators may create Conditional Access policies and may forget to add your emergency access accounts as an exclusion to those policies. This example ensures that all policies are updated to include your designated emergency access accounts.

Contingency planning

Things don't always work the way you want, when that happens you need a way to get back to a state where work can continue. The following example provides you a way to revert your policies to a known good contingency plan and disable other Conditional Access policies.

Community contribution

We are happy to support community contributions thorough GitHub Issues and Pull Requests in this GitHub repository.

Next steps

azure-ad-conditional-access-apis's People

Contributors

microsoft-github-operations[bot] avatar microsoftguyjflo avatar microsoftopensource avatar

Stargazers

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

Watchers

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

azure-ad-conditional-access-apis's Issues

"Template id" field read only error in the restore portion logic app

Everything works great until the end of the restore process logic app.

The template id field is causing the following error at the last steps of restore logic app. Though it has a null value, it is giving a 400 error. Attempts to strip the field or change it from null aren't fixing the issue either. I deleted and changed some values below for privacy:

"error": {
"code": "BadRequest",
"message": "1118: TemplateId is a read-only field and cannot be updated.",

RAW INPUTS:
{
"uri": "https://graph.microsoft.com/v1.0/identity/conditionalAccess/policies/erasedforprivacy00000",
"method": "PATCH",
"headers": {
"Content-Type": "application/json"
},
"authentication": {
"tenant": "",
"audience": "https://graph.microsoft.com",
"clientId": "
*****",
"secret": "sanitized",
"type": "ActiveDirectoryOAuth"
},
"body": "{"templateId":null,"displayName":"PolicyConditionalAccess1","state":"enabled","sessionControls":null,"conditions":{"userRiskLevels":[],"signInRiskLevels":[],"clientAppTypes":["all"],"servicePrincipalRiskLevels":[],"platforms":null,"locations":null,"devices":null,"clientApplications":null,"applications":{"includeApplications":["All"],"excludeApplications":[],"includeUserActions":[],"includeAuthenticationContextClassReferences":[],"applicationFilter":null},"users":{"includeUsers":["GuestsOrExternalUsers"],"excludeUsers":[],"includeGroups":[],"excludeGroups":[],"includeRoles":[],"excludeRoles":[],"includeGuestsOrExternalUsers":null,"excludeGuestsOrExternalUsers":null}},"grantControls":{"operator":"OR","builtInControls":["mfa"],"customAuthenticationFactors":[],"termsOfUse":[],"[email protected]":"https://graph.microsoft.com/v1.0/$metadata#identity/conditionalAccess/policies('erasedforprivacy00000')/grantControls/authenticationStrength/$entity\",\"authenticationStrength\":null}}{\"displayName\":\"PolicyConditionalAccess1\",\"modifiedDateTime\":\"2022-10-14T21:13:37.0687352Z\",\"state\":\"enabled\",\"sessionControls\":null,\"conditions\":{\"userRiskLevels\":[],\"signInRiskLevels\":[],\"clientAppTypes\":[\"all\"],\"servicePrincipalRiskLevels\":[],\"platforms\":null,\"locations\":null,\"devices\":null,\"clientApplications\":null,\"applications\":{\"includeApplications\":[\"All\"],\"excludeApplications\":[],\"includeUserActions\":[],\"includeAuthenticationContextClassReferences\":[],\"applicationFilter\":null},\"users\":{\"includeUsers\":[\"GuestsOrExternalUsers\"],\"excludeUsers\":[],\"includeGroups\":[],\"excludeGroups\":[],\"includeRoles\":[],\"excludeRoles\":[],\"includeGuestsOrExternalUsers\":null,\"excludeGuestsOrExternalUsers\":null}},\"grantControls\":{\"operator\":\"OR\",\"builtInControls\":[\"mfa\"],\"customAuthenticationFactors\":[],\"termsOfUse\":[],\"[email protected]\":\"https://graph.microsoft.com/v1.0/$metadata#identity/conditionalAccess/policies('erasedforprivacy00000')/grantControls/authenticationStrength/$entity\",\"authenticationStrength\":null}}"
}

Documentation - please clarify what's meant by test/preproduction environment

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [x ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

'preproduction environment' is mentioned in this page:
https://github.com/Azure-Samples/azure-ad-conditional-access-apis/blob/main/02-test/readme.md

Please clarify - does this imply two separate AAD directories, one for prod and one for preprod?

Missing Ca rule

Please provide us with the following information:

This issue is for a: (mark with an x)

- [x ] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

I have 11 CA policies in my tenant but the cmdlet Get-AzureADMSConditionalAccessPolicy only returns 10
The missing Ca rule was invalid due the usage of a preview feature, which was removed and now the configuration is not existing anymore. (Empty user action)

Any log messages given by the failure

Expected/desired behavior

I would expect at least an error or an information from the cmdlet.

OS and Version?

Windows 10

Versions

PS C:\ $PSVersionTable

Name Value


PSVersion 5.1.19041.1
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.1
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Mention any other details that might be useful

I think it is not happening very often but could help to troubleshoot misconfigured CA policies


Thanks! We'll be in touch soon.

New-AzureADMSConditionalAccessPolicy : Cannot bind parameter 'Conditions'


This issue is for a: (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

When running your specific $conditions to create the CA Policy I receive an error. I am authenticated with the global admin on the tenant, the account is also a part of the 'Conditional Access Administrators' role.
Even if I write my own conditions in I have the same error.
The only amendment I had made to your script was the $conditions.users.includegroups for a group Id in the tenant.

Any log messages given by the failure

PS C:\Windows\system32> New-AzureADMSConditionalAccessPolicy -DisplayName "CA0002: Require MFA for medium + sign-in risk" -State "enabledForReportingButNotEnforced" -Conditions $conditions -GrantControls $controls

New-AzureADMSConditionalAccessPolicy : Cannot bind parameter 'Conditions'. Cannot convert the "class ConditionalAccessConditionSet {
Applications: class ConditionalAccessApplicationCondition {
IncludeApplications: System.Collections.Generic.List1[System.String] ExcludeApplications: IncludeUserActions: IncludeProtectionLevels: } Users: class ConditionalAccessUserCondition { IncludeUsers: ExcludeUsers: IncludeGroups: System.Collections.Generic.List1[System.String]
ExcludeGroups:
IncludeRoles:
ExcludeRoles:
}
Platforms:
Locations:
SignInRiskLevels: System.Collections.Generic.List`1[Microsoft.Open.MSGraph.Model.ConditionalAccessRiskLevel]
ClientAppTypes:
}
" value of type "Microsoft.Open.MSGraph.Model.ConditionalAccessConditionSet" to type "Microsoft.Open.MSGraph.Model.ConditionalAccessConditionSet".
At line:1 char:154

  • ... e "enabledForReportingButNotEnforced" -Conditions $conditions -GrantC ...
  •                                                   ~~~~~~~~~~~
    
    • CategoryInfo : InvalidArgument: (:) [New-AzureADMSConditionalAccessPolicy], ParameterBindingException
    • FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Open.MSGraphBeta.PowerShell.NewAzureADMSConditionalAccessPolicy

Expected/desired behavior

No error

OS and Version?

Versions

Mention any other details that might be useful

If I am being a noob, then I am very sorry! Have looked into Intune and Azure deployment for so long my brain is mush.


Documentation not up to Date

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [x] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Just to trying to follow up the instruction here.

Any log messages given by the failure

There are many issues not just in the logs due to outdated instructions.

Expected/desired behavior

To get clear and up to date instructions with the new sections in Azure.

OS and Version?

This is Azure platform; OS does not affect platform behavior.

Versions

111.4

Mention any other details that might be useful

Please update the instructions on this guide, there are many sections that don't apply anymore due to the updates to Azure in the last 5 months.

Get-AzureADMSConditionalAccessPolicy throws an error

Please provide us with the following information:

This issue is for a: (mark with an x)

- [x ] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Install latest AzureADPreview from nuget (2.0.2.149)
Run the command Get-AzureADMSConditionalAccessPolicy

Any log messages given by the failure

Get-AzureADMSConditionalAccessPolicy : Error converting value "linux" to type 'Microsoft.Open.MSGraph.Model.ConditionalAccessDevicePlatforms'. Path 'value[29].conditions.platforms.includePlatforms[0]', line 1, position 31005.
At line:1 char:1

  • Get-AzureADMSConditionalAccessPolicy
  •   + CategoryInfo          : NotSpecified: (:) [Get-AzureADMSConditionalAccessPolicy], ApiException
      + FullyQualifiedErrorId : Microsoft.Open.MSGraphBeta.Client.ApiException,Microsoft.Open.MSGraphBeta.PowerShell.GetAzureADMSConditionalAccessPolicy
    
    

Expected/desired behavior

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)
Windows 11

Versions

AzureADPreview from nuget (2.0.2.149)

Mention any other details that might be useful


Thanks! We'll be in touch soon.

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.