@@ -65,7 +65,7 @@ Function AddResourcePermission($requiredAccess, `
6565}
6666
6767#
68- # Exemple : GetRequiredPermissions "Microsoft Graph" "Graph.Read|User.Read"
68+ # Example : GetRequiredPermissions "Microsoft Graph" "Graph.Read|User.Read"
6969# See also: http://stackoverflow.com/questions/42164581/how-to-configure-a-new-azure-ad-application-through-powershell
7070Function GetRequiredPermissions ([string ] $applicationDisplayName , [string ] $requiredDelegatedPermissions , [string ]$requiredApplicationPermissions , $servicePrincipal )
7171{
@@ -129,18 +129,18 @@ Function ReplaceInTextFile([string] $configFilePath, [System.Collections.HashTab
129129 Set-Content - Path $configFilePath - Value $lines - Force
130130}
131131
132-
133132Set-Content - Value " <html><body><table>" - Path createdApps.html
134133Add-Content - Value " <thead><tr><th>Application</th><th>AppId</th><th>Url in the Azure portal</th></tr></thead><tbody>" - Path createdApps.html
135134
135+ $ErrorActionPreference = " Stop"
136+
136137Function ConfigureApplications
137138{
138139<# . Description
139140 This function creates the Azure AD applications for the sample in the provided Azure AD tenant and updates the
140141 configuration files in the client and service project of the visual studio solution (App.Config and Web.Config)
141142 so that they are consistent with the Applications parameters
142143#>
143-
144144 $commonendpoint = " common"
145145
146146 # $tenantId is the Active Directory Tenant. This is a GUID which represents the "Directory ID" of the AzureAD tenant
@@ -172,7 +172,7 @@ Function ConfigureApplications
172172 $tenant = Get-AzureADTenantDetail
173173 $tenantName = ($tenant.VerifiedDomains | Where { $_._Default -eq $True }).Name
174174
175- # Get the user running the script
175+ # Get the user running the script to add the user as the app owner
176176 $user = Get-AzureADUser - ObjectId $creds.Account.Id
177177
178178 # Create the pythonwebapp AAD application
@@ -182,15 +182,16 @@ Function ConfigureApplications
182182 $fromDate = [DateTime ]::Now;
183183 $key = CreateAppKey - fromDate $fromDate - durationInYears 2 - pw $pw
184184 $pythonwebappAppKey = $pw
185+ # create the application
185186 $pythonwebappAadApplication = New-AzureADApplication - DisplayName " python-webapp" `
186- - LogoutUrl " http://localhost:5000/logout" `
187187 - ReplyUrls " http://localhost:5000/getAToken" `
188188 - IdentifierUris " https://$tenantName /python-webapp" `
189189 - AvailableToOtherTenants $True `
190190 - PasswordCredentials $key `
191191 - Oauth2AllowImplicitFlow $true `
192192 - PublicClient $False
193193
194+ # create the service principal of the newly created application
194195 $currentAppId = $pythonwebappAadApplication.AppId
195196 $pythonwebappServicePrincipal = New-AzureADServicePrincipal - AppId $currentAppId - Tags {WindowsAzureActiveDirectoryIntegratedApp}
196197
@@ -215,7 +216,7 @@ Function ConfigureApplications
215216 # Add Required Resources Access (from 'pythonwebapp' to 'Microsoft Graph')
216217 Write-Host " Getting access from 'pythonwebapp' to 'Microsoft Graph'"
217218 $requiredPermissions = GetRequiredPermissions - applicationDisplayName " Microsoft Graph" `
218- - requiredDelegatedPermissions " User.Read " `
219+ - requiredDelegatedPermissions " User.ReadBasic.All " `
219220
220221 $requiredResourcesAccess.Add ($requiredPermissions )
221222
@@ -235,7 +236,8 @@ Function ConfigureApplications
235236# Pre-requisites
236237if ((Get-Module - ListAvailable - Name " AzureAD" ) -eq $null ) {
237238 Install-Module " AzureAD" - Scope CurrentUser
238- }
239+ }
240+
239241Import-Module AzureAD
240242
241243# Run interactively (will ask you for the tenant ID)
0 commit comments