Skip to content

Commit 418e488

Browse files
Kalyan Krishnajmprieur
authored andcommitted
Fixed a few issues with the generated PS scripts (#102)
1 parent fa1280b commit 418e488

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

3-WebApp-multi-APIs/AppCreationScripts/Cleanup.ps1

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,8 @@ This function removes the Azure AD applications for the sample. These applicatio
5555
if ($app)
5656
{
5757
Remove-AzureADApplication -ObjectId $app.ObjectId
58-
Write-Host "Removed."
58+
Write-Host "Removed WebApp."
59+
}
5960
}
60-
61-
}
6261

6362
Cleanup -Credential $Credential -tenantId $TenantId

3-WebApp-multi-APIs/AppCreationScripts/Configure.ps1

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ Function ConfigureApplications
145145
so that they are consistent with the Applications parameters
146146
#>
147147

148+
$commonendpoint = "common"
149+
148150
# $tenantId is the Active Directory Tenant. This is a GUID which represents the "Directory ID" of the AzureAD tenant
149151
# into which you want to create the apps. Look it up in the Azure portal in the "Properties" of the Azure AD.
150152

@@ -201,8 +203,8 @@ Function ConfigureApplications
201203
$owner = Get-AzureADApplicationOwner -ObjectId $webAppAadApplication.ObjectId
202204
if ($owner -eq $null)
203205
{
204-
Add-AzureADApplicationOwner -ObjectId $webAppAadApplication.ObjectId -RefObjectId $user.ObjectId
205-
Write-Host "'$($user.UserPrincipalName)' added as an application owner to app '$($webAppServicePrincipal.DisplayName)'"
206+
Add-AzureADApplicationOwner -ObjectId $webAppAadApplication.ObjectId -RefObjectId $user.ObjectId
207+
Write-Host "'$($user.UserPrincipalName)' added as an application owner to app '$($webAppServicePrincipal.DisplayName)'"
206208
}
207209

208210
Write-Host "Done creating the webApp application (WebApp)"
@@ -217,7 +219,21 @@ Function ConfigureApplications
217219
# Add Required Resources Access (from 'webApp' to 'Microsoft Graph')
218220
Write-Host "Getting access from 'webApp' to 'Microsoft Graph'"
219221
$requiredPermissions = GetRequiredPermissions -applicationDisplayName "Microsoft Graph" `
220-
-requiredDelegatedPermissions "User.Read";
222+
-requiredDelegatedPermissions "User.Read" `
223+
224+
$requiredResourcesAccess.Add($requiredPermissions)
225+
226+
# Add Required Resources Access (from 'webApp' to 'Windows Azure Service Management API')
227+
Write-Host "Getting access from 'webApp' to 'Windows Azure Service Management API'"
228+
$requiredPermissions = GetRequiredPermissions -applicationDisplayName "Windows Azure Service Management API" `
229+
-requiredDelegatedPermissions "user_impersonation" `
230+
231+
$requiredResourcesAccess.Add($requiredPermissions)
232+
233+
# Add Required Resources Access (from 'webApp' to 'Azure Storage')
234+
Write-Host "Getting access from 'webApp' to 'Azure Storage'"
235+
$requiredPermissions = GetRequiredPermissions -applicationDisplayName "Azure Storage" `
236+
-requiredDelegatedPermissions "user_impersonation" `
221237

222238
$requiredResourcesAccess.Add($requiredPermissions)
223239

@@ -226,11 +242,11 @@ Function ConfigureApplications
226242
Write-Host "Granted permissions."
227243

228244
# Update config file for 'webApp'
229-
$configFile = $pwd.Path + "\..\active-directory-aspnetcore-webapp-openidconnect-v2\appsettings.json"
245+
$configFile = $pwd.Path + "\..\appsettings.json"
230246
Write-Host "Updating the sample code ($configFile)"
231-
$dictionary = @{ "ClientId" = $webAppAadApplication.AppId;"TenantId" = $tenantId;"Domain" = $tenantName;"TenantId" = $webAppAppKey };
247+
$dictionary = @{ "ClientId" = $webAppAadApplication.AppId;"TenantId" = $tenantId;"Domain" = $tenantName;"ClientSecret" = $webAppAppKey };
232248
UpdateTextFile -configFilePath $configFile -dictionary $dictionary
233-
249+
234250
Add-Content -Value "</tbody></table></body></html>" -Path createdApps.html
235251
}
236252

3-WebApp-multi-APIs/AppCreationScripts/sample.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"DelegatedPermissions": [ "User.Read" ]
2727
},
2828
{
29-
"Resource": "Azure Service Management",
29+
"Resource": "Windows Azure Service Management API",
3030
"DelegatedPermissions": [ "user_impersonation" ]
3131
},
3232
{

0 commit comments

Comments
 (0)