Skip to content

Commit 354a747

Browse files
committed
Clarify ACS secret renewal after principal creation streamline
1 parent 2592a2e commit 354a747

File tree

2 files changed

+51
-3
lines changed

2 files changed

+51
-3
lines changed

docs/sp-add-ins/add-ins-and-azure-acs-retirements-faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ No, both CSOM (client-side object model) and JSOM (JavaScript object model) will
7777

7878
## When I use appregnew.aspx the created ACS principals show up in Entra
7979

80-
As of December 2024 we've streamlined the app creation flow and as a result ACS principals created using appregnew.aspx now show are created as "regular" Entra app principal versus previously service principals with `legacyServicePrincipal` property set to `Legacy`. These app principals are detected by the [Microsoft 365 Assessment tool](https://aka.ms/microsoft365assessmenttool), however you need version 1.10.0 to ensure the principal validity is correctly reported.
80+
As of December 2024 we've streamlined the app creation flow and as a result ACS principals created using appregnew.aspx now show are created as "regular" Entra app principal versus previously service principals with `legacyServicePrincipal` property set to `Legacy`. These app principals are detected by the [Microsoft 365 Assessment tool](https://aka.ms/microsoft365assessmenttool), however you need version 1.10.0 to ensure the principal validity is correctly reported. Note, if you want to renew the secret of these principals ensure you're using the right approach as described in [Replace an expiring client secret in a SharePoint Add-in](replace-an-expiring-client-secret-in-a-sharepoint-add-in.md).
8181

8282
## Do I need to delete Azure ACS principals that are not needed anymore?
8383

docs/sp-add-ins/replace-an-expiring-client-secret-in-a-sharepoint-add-in.md

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Replace an expiring client secret in a SharePoint Add-in
33
description: Add a new client secret for a SharePoint Add-in that is registered with AppRegNew.aspx.
4-
ms.date: 09/09/2024
4+
ms.date: 04/16/2025
55
ms.localizationpriority: high
66
ms.service: sharepoint
77
---
@@ -30,7 +30,14 @@ Ensure the following before you begin:
3030
- You have installed Microsoft Graph Powershell SDK: [Install the Microsoft Graph PowerShell SDK](/powershell/microsoftgraph/installation)
3131
- You're a tenant administrator (or having **Application.ReadWrite.All** permission) for the Microsoft 365 tenant where the add-in was registered with the **AppRegNew.aspx** page.
3232

33-
## Generate a new secret
33+
## Understand the type of your ACS principal before renewing the secret
34+
35+
Historically ACS principals were created as Microsoft Entra service principals having the `servicePrincipalType` set to `Legacy`. As of December 2024 the Microsoft Entra principal creation has been streamlined and ACS principals are now created as application principals in Microsoft Entra. If you browse the Microsoft Entra applications you'll now be able to see the ACS principal you've created as of December 2024. ACS principal creation typically is done using `appregnew.aspx`.
36+
37+
> [!Important]
38+
> Due to this alternate creation the renewal of ACS principals also differs, below two chapters show both approaches, for the ACS service principals and for the ACS application principals. Ensure you use the correct approach.
39+
40+
## Generate a new secret - for ACS service principals, created before December 2024
3441

3542
1. Create a client ID variable with the following line, using the client ID of the SharePoint Add-in as the parameter:
3643

@@ -97,6 +104,47 @@ Ensure the following before you begin:
97104
> [!IMPORTANT]
98105
> Wait at least 24 hours for the propagation of the new ClientSecret to SharePoint.
99106
107+
## Generate a new secret - for ACS application principals, created from December 2024 onwards
108+
109+
```PowerShell
110+
Connect-Graph -Scopes "Application.ReadWrite.All,Directory.ReadWrite.All"
111+
$applicationId = '<your client id>' # replace with your app id
112+
$appPrincipal = Get-MgApplication -Filter "AppId eq '$applicationId'"
113+
$params = @{
114+
PasswordCredential = @{
115+
DisplayName = "NewSecret" # Replace with a friendly name.
116+
}
117+
}
118+
$result = Add-MgApplicationPassword -ApplicationId $appPrincipal.Id -BodyParameter $params
119+
$base64Secret = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($result.SecretText))
120+
$dtStart = $result.StartDateTime
121+
$dtEnd = $result.EndDateTime
122+
$keyCredentials = @(
123+
@{
124+
Type = "Symmetric"
125+
Usage = "Verify"
126+
Key = [System.Text.Encoding]::UTF8.GetBytes($result.SecretText)
127+
StartDateTime = $dtStart
128+
EndDateTime = $dtEnd
129+
},
130+
@{
131+
Type = "Symmetric"
132+
Usage = "Sign"
133+
Key = [System.Text.Encoding]::UTF8.GetBytes($result.SecretText)
134+
StartDateTime = $dtStart
135+
EndDateTime = $dtEnd
136+
}
137+
)
138+
# Add existing valid key credentials to the $keyCredentials
139+
$appPrincipal.KeyCredentials |%{if ($_.EndDateTime -gt [DateTime]::UtcNow) {$keyCredentials += @($_)}}
140+
Update-MgApplication -ApplicationId $appPrincipal.Id -KeyCredentials $keyCredentials # Update keys
141+
$result.SecretText # Print secret text
142+
$base64Secret # Print base64 secret
143+
$result.EndDateTime # Print the end date.
144+
```
145+
146+
> [!IMPORTANT]
147+
> Wait at least 24 hours for the propagation of the new ClientSecret to SharePoint.
100148
101149
## Update the remote web application in Visual Studio to use the new secret
102150

0 commit comments

Comments
 (0)