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
Copy file name to clipboardExpand all lines: AppCreationScripts/AppCreationScripts.md
+46-10Lines changed: 46 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,32 @@
1
1
# Registering the Azure Active Directory applications and updating the configuration files for this sample using PowerShell scripts
2
2
3
+
## Overview
4
+
5
+
### Quick summary
6
+
7
+
1. On Windows run PowerShell and navigate to the root of the cloned directory
8
+
1. In PowerShell run:
9
+
```PowerShell
10
+
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process -Force
11
+
```
12
+
1. Run the script to create your Azure AD application and configure the code of the sample application accordinly. (Other ways of running the scripts are described below)
13
+
```PowerShell
14
+
.\AppCreationScripts\Configure.ps1
15
+
```
16
+
1. Open the Visual Studio solution and click start
17
+
18
+
### More details
19
+
20
+
The following paragraphs:
21
+
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
+
3
30
## Goal of the scripts
4
31
5
32
### Presentation of the scripts
@@ -26,21 +53,30 @@ The `Configure.ps1` will stop if it tries to create an Azure AD application whic
26
53
27
54
### Pre-requisites
28
55
29
-
To use the app creation scripts:
30
-
31
56
1. Open PowerShell (On Windows, press `Windows-R` and type `PowerShell` in the search window)
32
57
2. Navigate to the root directory of the project.
33
-
3. Until you change it, the default Execution Policy for scripts is usually `Restricted`. In order to run the PowerShell script you need to set the Execution Policy to `Unrestricted`. You can set this just for the current PowerShell process by running the command:
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:
34
59
```PowerShell
35
-
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Unrestricted
60
+
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
+
37
65
4. If you have never done it already, in the PowerShell window, install the AzureAD PowerShell modules. For this:
38
66
39
67
1. Open PowerShell as admin (On Windows, Search Powershell in the search bar, right click on it and select Run as administrator).
40
68
2. Type:
41
-
```PowerShell
42
-
Install-Module AzureAD
43
-
```
69
+
```PowerShell
70
+
Install-Module AzureAD
71
+
```
72
+
73
+
or if you cannot be administrator on your machine, run:
74
+
```PowerShell
75
+
Install-Module AzureAD -Scope CurrentUser
76
+
```
77
+
78
+
### Run the script and start running
79
+
44
80
5. Go to the `AppCreationScripts` sub-folder. From the folder where you cloned the repo,
45
81
```PowerShell
46
82
cd AppCreationScripts
@@ -56,9 +92,9 @@ You're done. this just works!
56
92
We advise four ways of running the script:
57
93
58
94
- Interactive: you will be prompted for credentials, and the scripts decide in which tenant to create the objects,
59
-
- non-interactive: you will provide crendentials, and the scripts decide in which tenant to create the objects,
60
-
- Interactive in specific tenant: you will be prompted for credentials, and the scripts decide in which tenant to create the objects,
61
-
- non-interactive in specific tenant: you will provide crendentials, 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.
[Parameter(Mandatory=$False,HelpMessage='Tenant ID (This is a GUID which represents the "Directory ID" of the AzureAD tenant into which you want to create the apps')]
5
+
[string] $tenantId
6
+
)
7
+
8
+
if ((Get-Module-ListAvailable -Name "AzureAD") -eq$null) {
9
+
Install-Module"AzureAD"-Scope CurrentUser
10
+
}
2
11
Import-Module AzureAD
3
12
$ErrorActionPreference='Stop'
4
13
@@ -8,15 +17,7 @@ Function Cleanup
8
17
.Description
9
18
This function removes the Azure AD applications for the sample. These applications were created by the Configure.ps1 script
10
19
#>
11
-
[CmdletBinding()]
12
-
param(
13
-
[Parameter(HelpMessage='Tenant ID (This is a GUID which represents the "Directory ID" of the AzureAD tenant into which you want to create the apps')]
14
-
[PSCredential] $Credential,
15
-
[string] $tenantId
16
-
)
17
20
18
-
process
19
-
{
20
21
# $tenantId is the Active Directory Tenant. This is a GUID which represents the "Directory ID" of the AzureAD tenant
21
22
# into which you want to create the apps. Look it up in the Azure portal in the "Properties" of the Azure AD.
22
23
@@ -49,22 +50,25 @@ This function removes the Azure AD applications for the sample. These applicatio
49
50
Write-Host"Cleaning-up applications from tenant '$tenantName'"
50
51
51
52
Write-Host"Removing 'service' (TodoListService-ManualJwt) if needed"
Copy file name to clipboardExpand all lines: AppCreationScripts/Configure.ps1
+54-42Lines changed: 54 additions & 42 deletions
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,9 @@
1
1
[CmdletBinding()]
2
-
param(
3
-
[PSCredential] $Credential,
4
-
[Parameter(HelpMessage='Tenant ID (This is a GUID which represents the "Directory ID" of the AzureAD tenant into which you want to create the apps')]
5
-
[string] $tenantId
6
-
)
2
+
param(
3
+
[PSCredential] $Credential,
4
+
[Parameter(Mandatory=$False,HelpMessage='Tenant ID (This is a GUID which represents the "Directory ID" of the AzureAD tenant into which you want to create the apps')]
5
+
[string] $tenantId
6
+
)
7
7
8
8
<#
9
9
This script creates the Azure AD applications needed for this sample and updates the configuration files
@@ -15,10 +15,6 @@
15
15
2) in the PowerShell window, type: Install-Module AzureAD
16
16
17
17
There are four ways to run this script. For more information, read the AppCreationScripts.md file in the same folder as this script.
18
-
19
-
# Parameters
20
-
# $tenantId is the Active Directory Tenant. This is a GUID which represents the "Directory ID" of the AzureAD tenant
21
-
# into which you want to create the apps. Look it up in the Azure portal in the "Properties" of the Azure AD.
22
18
#>
23
19
24
20
# Adds the requiredAccesses (expressed as a pipe separated string) to the requiredAccess structure
@@ -66,7 +62,7 @@ Function GetRequiredPermissions([string] $applicationDisplayName, [string] $requ
0 commit comments