You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Import issues
* Black reformatting
* Dont use flask-session package
* Add sample
* Use .env in b2c
* Reimport os
* Updates per comments
* Trailing comma
* Readme and Powershell updates
* Update README.md
Co-authored-by: Ray Luo <[email protected]>
* readme updates
* Address B2C issues
* TENANT_ID vs TENANT_NAME
* Update app_config.py
Co-authored-by: Ray Luo <[email protected]>
* Tenant name for b2c
* Flask-session instead of Flask-session2
* Updated scripts
---------
Co-authored-by: Ray Luo <[email protected]>
# Registering the sample apps with Microsoft Identity Platform and updating the configuration files using PowerShell scripts
1
+
# Registering sample apps with the Microsoft identity platform and updating configuration files using PowerShell
2
2
3
3
## Overview
4
4
5
5
### Quick summary
6
6
7
-
1. On Windows run PowerShell and navigate to the root of the cloned directory
7
+
1. On Windows, run PowerShell as **Administrator** and navigate to the root of the cloned directory
8
8
1. In PowerShell run:
9
+
9
10
```PowerShell
10
11
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process -Force
11
12
```
12
-
1. Run the script to create your Azure AD application and configure the code of the sample application accordingly. (Other ways of running the scripts are described below)
13
+
14
+
1. Run the script to create your Azure AD application and configure the code of the sample application accordingly.
15
+
13
16
```PowerShell
14
-
.\AppCreationScripts\Configure.ps1
17
+
cd .\AppCreationScripts\
18
+
.\Configure.ps1 -TenantId "your test tenant's id" -AzureEnvironmentName "[Optional] - Azure environment, defaults to 'Global'"
15
19
```
16
-
1. Open the Visual Studio solution and click start
17
20
18
21
### More details
19
22
20
-
The following paragraphs:
23
+
-[Goal of the provided scripts](#goal-of-the-provided-scripts)
24
+
-[Presentation of the scripts](#presentation-of-the-scripts)
25
+
-[Usage pattern for tests and DevOps scenarios](#usage-pattern-for-tests-and-DevOps-scenarios)
26
+
-[How to use the app creation scripts?](#how-to-use-the-app-creation-scripts)
27
+
-[Pre-requisites](#pre-requisites)
28
+
-[Run the script and start running](#run-the-script-and-start-running)
29
+
-[Four ways to run the script](#four-ways-to-run-the-script)
30
+
-[Option 1 (interactive)](#option-1-interactive)
31
+
-[Option 2 (Interactive, but create apps in a specified tenant)](#option-3-Interactive-but-create-apps-in-a-specified-tenant)
32
+
-[Running the script on Azure Sovereign clouds](#running-the-script-on-Azure-Sovereign-clouds)
21
33
22
-
-[Present the scripts](#presentation-of-the-scripts) and explain their [usage patterns](#usage-pattern-for-tests-and-devops-scenarios) for test and DevOps scenarios.
23
-
- Explain the [pre-requisites](#pre-requisites)
24
-
- Explain [four ways of running the scripts](#four-ways-to-run-the-script):
25
-
-[Interactively](#option-1-interactive) to create the app in your home tenant
26
-
-[Passing credentials](#option-2-non-interactive) to create the app in your home tenant
27
-
-[Interactively in a specific tenant](#option-3-interactive-but-create-apps-in-a-specified-tenant)
28
-
-[Passing credentials in a specific tenant](#option-4-non-interactive-and-create-apps-in-a-specified-tenant)
29
-
30
-
## Goal of the scripts
34
+
## Goal of the provided scripts
31
35
32
36
### Presentation of the scripts
33
37
@@ -36,92 +40,83 @@ This sample comes with two PowerShell scripts, which automate the creation of th
36
40
These scripts are:
37
41
38
42
-`Configure.ps1` which:
39
-
- creates Azure AD applications and their related objects (permissions, dependencies, secrets),
40
-
- changes the configuration files in the C# and JavaScript projects.
43
+
- creates Azure AD applications and their related objects (permissions, dependencies, secrets, app roles),
44
+
- changes the configuration files in the sample projects.
41
45
- creates a summary file named `createdApps.html` in the folder from which you ran the script, and containing, for each Azure AD application it created:
42
46
- the identifier of the application
43
47
- the AppId of the application
44
48
- the url of its registration in the [Azure portal](https://portal.azure.com).
45
49
46
-
-`Cleanup.ps1` which cleans-up the Azure AD objects created by `Configure.ps1`. Note that this script does not revert the changes done in the configuration files, though. You will need to undo the change from source control (from Visual Studio, or from the command line using, for instance, git reset).
50
+
-`Cleanup.ps1` which cleans-up the Azure AD objects created by `Configure.ps1`. Note that this script does not revert the changes done in the configuration files, though. You will need to undo the change from source control (from Visual Studio, or from the command line using, for instance, `git reset`).
47
51
48
52
### Usage pattern for tests and DevOps scenarios
49
53
50
54
The `Configure.ps1` will stop if it tries to create an Azure AD application which already exists in the tenant. For this, if you are using the script to try/test the sample, or in DevOps scenarios, you might want to run `Cleanup.ps1` just before `Configure.ps1`. This is what is shown in the steps below.
51
55
52
-
## How to use the app creation scripts?
56
+
## How to use the app creation scripts?
53
57
54
58
### Pre-requisites
55
59
56
60
1. Open PowerShell (On Windows, press `Windows-R` and type `PowerShell` in the search window)
57
-
2. Navigate to the root directory of the project.
58
-
3. Until you change it, the default [Execution Policy](https:/go.microsoft.com/fwlink/?LinkID=135170) for scripts is usually `Restricted`. In order to run the PowerShell script you need to set the Execution Policy to `RemoteSigned`. You can set this just for the current PowerShell process by running the command:
61
+
1. Navigate to the root directory of the project.
62
+
1. Until you change it, the default [Execution Policy](https:/go.microsoft.com/fwlink/?LinkID=135170) for scripts is usually `Restricted`. In order to run the PowerShell script you need to set the Execution Policy to `RemoteSigned`. You can set this just for the current PowerShell process by running the command:
63
+
59
64
```PowerShell
60
65
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process
The scripts install the required PowerShell module (AzureAD) for the current user if needed. However, if you want to install if for all users on the machine, you can follow the following steps:
64
67
65
-
4. If you have never done it already, in the PowerShell window, install the AzureAD PowerShell modules. For this:
The scripts install the required PowerShell module (Microsoft.Graph.Applications) for the current user if needed. However, if you want to install if for all users on the machine, you can follow the following steps:
66
71
67
-
1. Open PowerShell as admin (On Windows, Search Powershell in the search bar, right click on it and select Run as administrator).
72
+
1. If you have never done it already, in the PowerShell window, install the Microsoft.Graph.Applications PowerShell modules. For this:
73
+
74
+
1. Open PowerShell as admin (On Windows, Search Powershell in the search bar, right click on it and select **Run as administrator**).
68
75
2. Type:
76
+
69
77
```PowerShell
70
-
Install-Module AzureAD
78
+
Install-Module Microsoft.Graph.Applications
71
79
```
72
80
73
81
or if you cannot be administrator on your machine, run:
5. Go to the `AppCreationScripts` sub-folder. From the folder where you cloned the repo,
89
+
1. Go to the `AppCreationScripts` sub-folder. From the folder where you cloned the repo,
90
+
81
91
```PowerShell
82
92
cd AppCreationScripts
83
93
```
84
-
6. Run the scripts. See below for the [four options](#four-ways-to-run-the-script) to do that.
85
-
7. Open the Visual Studio solution, and in the solution's context menu, choose **Set Startup Projects**.
86
-
8. select **Start** for the projects
87
94
88
-
You're done. this just works!
95
+
1. Run the scripts. See below for the [four options](#four-ways-to-run-the-script) to do that.
96
+
97
+
You're done!
89
98
90
-
### Four ways to run the script
99
+
### Two ways to run the script
91
100
92
101
We advise four ways of running the script:
93
102
94
103
- Interactive: you will be prompted for credentials, and the scripts decide in which tenant to create the objects,
95
-
- non-interactive: you will provide credentials, and the scripts decide in which tenant to create the objects,
96
-
- Interactive in specific tenant: you will provide the tenant in which you want to create the objects and then you will be prompted for credentials, and the scripts will create the objects,
97
-
- non-interactive in specific tenant: you will provide tenant in which you want to create the objects and credentials, and the scripts will create the objects.
104
+
- Interactive in specific tenant: you will provide the tenant in which you want to create the objects and then you will be prompted for credentials, and the scripts will create the objects,
98
105
99
106
Here are the details on how to do this.
100
107
101
108
#### Option 1 (interactive)
102
109
103
-
- Just run ``. .\Configure.ps1``, and you will be prompted to sign-in (email address, password, and if needed MFA).
110
+
- Just run ``.\Configure.ps1``, and you will be prompted to sign-in (email address, password, and if needed MFA).
104
111
- The script will be run as the signed-in user and will use the tenant in which the user is defined.
105
112
106
113
Note that the script will choose the tenant in which to create the applications, based on the user. Also to run the `Cleanup.ps1` script, you will need to re-sign-in.
107
114
108
-
#### Option 2 (non-interactive)
109
-
110
-
When you know the indentity and credentials of the user in the name of whom you want to create the applications, you can use the non-interactive approach. It's more adapted to DevOps. Here is an example of script you'd want to run in a PowerShell Window
#### Option 4 (non-interactive, and create apps in a specified tenant)
131
+
###Running the script on Azure Sovereign clouds
137
132
138
-
This option combines option 2 and option 3: it creates the application in a specific tenant. See option 3 for the way to get the tenant Id. Then run:
133
+
All the four options listed above can be used on any Azure Sovereign clouds. By default, the script targets `AzureCloud`, but it can be changed using the parameter `-AzureEnvironmentName`.
0 commit comments