Skip to content

Commit 245853f

Browse files
committed
Merge branch 'main' of https://github.com/MicrosoftDocs/azure-docs-pr into migstv2
2 parents 74279c7 + 5378ec1 commit 245853f

File tree

73 files changed

+1688
-963
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1688
-963
lines changed

.openpublishing.redirection.azure-monitor.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{
22
"redirections": [
3-
{
3+
{
4+
"source_path_from_root": "/articles/azure-monitor/snapshot-debugger/snapshot-collector-release-notes.md",
5+
"redirect_url": "/azure/azure-monitor/snapshot-debugger/snapshot-debugger#release-notes-for-microsoftapplicationinsightssnapshotcollector",
6+
"redirect_document_id": false
7+
},
8+
{
49
"source_path_from_root": "/articles/azure-monitor/best-practices.md",
510
"redirect_url": "/azure/azure-monitor/getting-started",
611
"redirect_document_id": false

articles/active-directory/develop/includes/web-app/quickstart-aspnet.md

Lines changed: 40 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ See [How the sample works](#how-the-sample-works) for an illustration.
2626
## Prerequisites
2727

2828
* An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
29-
* [Visual Studio 2019](https://visualstudio.microsoft.com/vs/)
29+
* [Visual Studio 2022](https://visualstudio.microsoft.com/vs/)
3030
* [.NET Framework 4.7.2+](https://dotnet.microsoft.com/download/visual-studio-sdks)
3131

3232
## Register and download the app
@@ -71,11 +71,11 @@ If you want to manually configure your application and code sample, use the foll
7171
3. Depending on the version of Visual Studio, you might need to right-click the project **AppModelv2-WebApp-OpenIDConnect-DotNet** and then select **Restore NuGet packages**.
7272
4. Open the Package Manager Console by selecting **View** > **Other Windows** > **Package Manager Console**. Then run `Update-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform -r`.
7373

74-
5. Edit *Web.config* and replace the parameters `ClientId`, `Tenant`, and `redirectUri` with:
75-
```xml
76-
<add key="ClientId" value="Enter_the_Application_Id_here" />
77-
<add key="Tenant" value="Enter_the_Tenant_Info_Here" />
78-
<add key="redirectUri" value="https://localhost:44368/" />
74+
5. Edit *appsettings.json* and replace the parameters `ClientId`, `Tenant`, and `redirectUri` with:
75+
```json
76+
"ClientId" :"Enter_the_Application_Id_here" />
77+
"TenantId": "Enter_the_Tenant_Info_Here" />
78+
"RedirectUri" :"https://localhost:44368/" />
7979
```
8080
In that code:
8181

@@ -100,48 +100,30 @@ This section gives an overview of the code required to sign in users. This overv
100100
You can set up the authentication pipeline with cookie-based authentication by using OpenID Connect in ASP.NET with OWIN middleware packages. You can install these packages by running the following commands in Package Manager Console within Visual Studio:
101101

102102
```powershell
103-
Install-Package Microsoft.Owin.Security.OpenIdConnect
103+
Install-Package Microsoft.Identity.Web.Owin
104+
Install-Package Microsoft.Identity.Web.MicrosoftGraph
104105
Install-Package Microsoft.Owin.Security.Cookies
105-
Install-Package Microsoft.Owin.Host.SystemWeb
106106
```
107107

108108
### OWIN startup class
109109

110110
The OWIN middleware uses a *startup class* that runs when the hosting process starts. In this quickstart, the *startup.cs* file is in the root folder. The following code shows the parameters that this quickstart uses:
111111

112112
```csharp
113-
public void Configuration(IAppBuilder app)
114-
{
115-
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
116-
117-
app.UseCookieAuthentication(new CookieAuthenticationOptions());
118-
app.UseOpenIdConnectAuthentication(
119-
new OpenIdConnectAuthenticationOptions
120-
{
121-
// Sets the client ID, authority, and redirect URI as obtained from Web.config
122-
ClientId = clientId,
123-
Authority = authority,
124-
RedirectUri = redirectUri,
125-
// PostLogoutRedirectUri is the page that users will be redirected to after sign-out. In this case, it's using the home page
126-
PostLogoutRedirectUri = redirectUri,
127-
Scope = OpenIdConnectScope.OpenIdProfile,
128-
// ResponseType is set to request the code id_token, which contains basic information about the signed-in user
129-
ResponseType = OpenIdConnectResponseType.CodeIdToken,
130-
// ValidateIssuer set to false to allow personal and work accounts from any organization to sign in to your application
131-
// To only allow users from a single organization, set ValidateIssuer to true and the 'tenant' setting in Web.config to the tenant name
132-
// To allow users from only a list of specific organizations, set ValidateIssuer to true and use the ValidIssuers parameter
133-
TokenValidationParameters = new TokenValidationParameters()
134-
{
135-
ValidateIssuer = false // Simplification (see note below)
136-
},
137-
// OpenIdConnectAuthenticationNotifications configures OWIN to send notification of failed authentications to the OnAuthenticationFailed method
138-
Notifications = new OpenIdConnectAuthenticationNotifications
139-
{
140-
AuthenticationFailed = OnAuthenticationFailed
141-
}
142-
}
143-
);
144-
}
113+
public void Configuration(IAppBuilder app)
114+
{
115+
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
116+
117+
app.UseCookieAuthentication(new CookieAuthenticationOptions());
118+
OwinTokenAcquirerFactory factory = TokenAcquirerFactory.GetDefaultInstance<OwinTokenAcquirerFactory>();
119+
120+
app.AddMicrosoftIdentityWebApp(factory);
121+
factory.Services
122+
.Configure<ConfidentialClientApplicationOptions>(options => { options.RedirectUri = "https://localhost:44368/"; })
123+
.AddMicrosoftGraph()
124+
.AddInMemoryTokenCaches();
125+
factory.Build();
126+
}
145127
```
146128

147129
|Where | Description |
@@ -155,10 +137,6 @@ public void Configuration(IAppBuilder app)
155137
| `TokenValidationParameters` | A list of parameters for token validation. In this case, `ValidateIssuer` is set to `false` to indicate that it can accept sign-ins from any personal, work, or school account type. |
156138
| `Notifications` | A list of delegates that can be run on `OpenIdConnect` messages. |
157139

158-
159-
> [!NOTE]
160-
> Setting `ValidateIssuer = false` is a simplification for this quickstart. In real applications, validate the issuer. See the samples to understand how to do that.
161-
162140
### Authentication challenge
163141

164142
You can force a user to sign in by requesting an authentication challenge in your controller:
@@ -182,6 +160,24 @@ public void SignIn()
182160

183161
You can protect a controller or controller actions by using the `[Authorize]` attribute. This attribute restricts access to the controller or actions by allowing only authenticated users to access the actions in the controller. An authentication challenge will then happen automatically when an unauthenticated user tries to access one of the actions or controllers decorated by the `[Authorize]` attribute.
184162

163+
### Call Microsoft Graph from the controller
164+
165+
You can call Microsoft Graph from the controller by getting the instance of GraphServiceClient using the `GetGraphServiceClient` extension method on the controller, like in the following code:
166+
167+
```csharp
168+
try
169+
{
170+
var me = await this.GetGraphServiceClient().Me.Request().GetAsync();
171+
ViewBag.Username = me.DisplayName;
172+
}
173+
catch (ServiceException graphEx) when (graphEx.InnerException is MicrosoftIdentityWebChallengeUserException)
174+
{
175+
HttpContext.GetOwinContext().Authentication.Challenge(OpenIdConnectAuthenticationDefaults.AuthenticationType);
176+
return View();
177+
}
178+
```
179+
180+
185181
[!INCLUDE [Help and support](../../../../../includes/active-directory-develop-help-support-include.md)]
186182

187183
## Next steps

articles/app-service/operating-system-functionality.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ At its core, App Service is a service running on top of the Azure PaaS (platform
4747
- An operating system drive (`%SystemDrive%`), whose size varies depending on the size of the VM.
4848
- A resource drive (`%ResourceDrive%`) used by App Service internally.
4949

50+
A best practice is to always use the environment variables `%SystemDrive%` and `%ResourceDrive%` instead of hard-coded file paths. The root path returned from these two environment variables has shifted over time from `d:\` to `c:\`. However, older applications hard-coded with file path references to `d:\` will continue to work because the App Service platform automatically remaps `d:\` to instead point at `c:\`. As noted above, it is highly recommended to always use the environment variables when building file paths and avoid confusion over platform changes to the default root file path.
51+
5052
It is important to monitor your disk utilization as your application grows. If the disk quota is reached, it can have adverse effects to your application. For example:
5153

5254
- The app may throw an error indicating not enough space on the disk.

articles/azure-app-configuration/enable-dynamic-configuration-aspnet-core.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,48 @@ The configuration refresh is triggered by the incoming requests to your web app.
230230

231231
![Launching updated quickstart app locally](./media/quickstarts/aspnet-core-app-launch-local-after.png)
232232

233+
## Logging and monitoring
234+
235+
Logs are output upon configuration refresh and contain detailed information on key-values retrieved from your App Configuration store and configuration changes made to your application.
236+
237+
- A default `ILoggerFactory` is added automatically when `services.AddAzureAppConfiguration()` is invoked. The App Configuration provider uses this `ILoggerFactory` to create an instance of `ILogger`, which outputs these logs. ASP.NET Core uses `ILogger` for logging by default, so you don't need to make additional code changes to enable logging for the App Configuration provider.
238+
- Logs are output at different log levels. The default level is `Information`.
239+
240+
| Log Level | Description |
241+
|---|---|
242+
| Debug | Logs include the key and label of key-values your application monitors for changes from your App Configuration store. The information also includes whether the key-value has changed compared with what your application has already loaded. Enable logs at this level to troubleshoot your application if a configuration change didn't happen as expected. |
243+
| Information | Logs include the keys of configuration settings updated during a configuration refresh. Values of configuration settings are omitted from the log to avoid leaking sensitive data. You can monitor logs at this level to ensure your application picks up expected configuration changes. |
244+
| Warning | Logs include failures and exceptions that occurred during configuration refresh. Occasional occurrences can be ignored because the configuration provider will continue using the cached data and attempt to refresh the configuration next time. You can monitor logs at this level for repetitive warnings that may indicate potential issues. For example, you rotated the connection string but forgot to update your application. |
245+
246+
You can enable logging at the `Debug` log level by adding the following example to your `appsettings.json` file. This example applies to all other log levels as well.
247+
```json
248+
"Logging": {
249+
"LogLevel": {
250+
"Microsoft.Extensions.Configuration.AzureAppConfiguration": "Debug"
251+
}
252+
}
253+
```
254+
- The logging category is `Microsoft.Extensions.Configuration.AzureAppConfiguration.Refresh`, which appears before each log. Here are some example logs at each log level:
255+
```console
256+
dbug: Microsoft.Extensions.Configuration.AzureAppConfiguration.Refresh[0]
257+
Key-value read from App Configuration. Change:'Modified' Key:'ExampleKey' Label:'ExampleLabel' Endpoint:'https://examplestore.azconfig.io'
258+
259+
info: Microsoft.Extensions.Configuration.AzureAppConfiguration.Refresh[0]
260+
Setting updated. Key:'ExampleKey'
261+
262+
warn: Microsoft.Extensions.Configuration.AzureAppConfiguration.Refresh[0]
263+
A refresh operation failed while resolving a Key Vault reference.
264+
Key vault error. ErrorCode:'SecretNotFound' Key:'ExampleKey' Label:'ExampleLabel' Etag:'6LaqgBQM9C_Do2XyZa2gAIfj_ArpT52-xWwDSLb2hDo' SecretIdentifier:'https://examplevault.vault.azure.net/secrets/ExampleSecret'
265+
```
266+
267+
Using `ILogger` is the preferred method in ASP.NET applications and is prioritized as the logging source if an instance of `ILoggerFactory` is present. However, if `ILoggerFactory` is not available, logs can alternatively be enabled and configured through the [instructions for .NET Core apps](./enable-dynamic-configuration-dotnet-core.md#logging-and-monitoring). For more information, see [logging in .NET Core and ASP.NET Core](/aspnet/core/fundamentals/logging).
268+
269+
> [!NOTE]
270+
> Logging is available if you use version **6.0.0** or later of any of the following packages.
271+
> - `Microsoft.Extensions.Configuration.AzureAppConfiguration`
272+
> - `Microsoft.Azure.AppConfiguration.AspNetCore`
273+
> - `Microsoft.Azure.AppConfiguration.Functions.Worker`
274+
233275
## Clean up resources
234276

235277
[!INCLUDE [azure-app-configuration-cleanup](../../includes/azure-app-configuration-cleanup.md)]

articles/azure-app-configuration/enable-dynamic-configuration-dotnet-core.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,47 @@ Calling the `ConfigureRefresh` method alone won't cause the configuration to ref
140140
> [!NOTE]
141141
> Since the cache expiration time was set to 10 seconds using the `SetCacheExpiration` method while specifying the configuration for the refresh operation, the value for the configuration setting will only be updated if at least 10 seconds have elapsed since the last refresh for that setting.
142142

143+
## Logging and monitoring
144+
145+
Logs are output upon configuration refresh and contain detailed information on key-values retrieved from your App Configuration store and configuration changes made to your application. If you have an ASP.NET Core application, see these instructions for [Logging and Monitoring in ASP.NET Core](./enable-dynamic-configuration-aspnet-core.md#logging-and-monitoring). Otherwise, you can enable logging using the instructions for [logging with the Azure SDK](/dotnet/azure/sdk/logging).
146+
147+
- Logs are output at different event levels. The default level is `Informational`.
148+
149+
| Event Level | Description |
150+
|---|---|
151+
| Verbose | Logs include the key and label of key-values your application monitors for changes from your App Configuration store. The information also includes whether the key-value has changed compared with what your application has already loaded. Enable logs at this level to troubleshoot your application if a configuration change didn't happen as expected. |
152+
| Informational | Logs include the keys of configuration settings updated during a configuration refresh. Values of configuration settings are omitted from the log to avoid leaking sensitive data. You can monitor logs at this level to ensure your application picks up expected configuration changes. |
153+
| Warning | Logs include failures and exceptions that occurred during configuration refresh. Occasional occurrences can be ignored because the configuration provider will continue using the cached data and attempt to refresh the configuration next time. You can monitor logs at this level for repetitive warnings that may indicate potential issues. For example, you rotated the connection string but forgot to update your application. |
154+
155+
You can enable logging at the `Verbose` event level by specifying the `EventLevel.Verbose` parameter, as done in the following example. These instructions apply to all other event levels as well. This example also enables logs for only the `Microsoft-Extensions-Configuration-AzureAppConfiguration-Refresh` category.
156+
```csharp
157+
using var listener = new AzureEventSourceListener((eventData, text) =>
158+
{
159+
if (eventData.EventSource.Name == "Microsoft-Extensions-Configuration-AzureAppConfiguration-Refresh")
160+
{
161+
Console.WriteLine("[{1}] {0}: {2}", eventData.EventSource.Name, eventData.Level, text);
162+
}
163+
}, EventLevel.Verbose);
164+
```
165+
- The logging category is `Microsoft-Extensions-Configuration-AzureAppConfiguration-Refresh`, which appears before each log. Here are some example logs at each event level:
166+
```console
167+
[Verbose] Microsoft-Extensions-Configuration-AzureAppConfiguration-Refresh:
168+
Key-value read from App Configuration. Change:'Modified' Key:'ExampleKey' Label:'ExampleLabel' Endpoint:'https://examplestore.azconfig.io'
169+
170+
[Informational] Microsoft-Extensions-Configuration-AzureAppConfiguration-Refresh:
171+
Setting updated. Key:'ExampleKey'
172+
173+
[Warning] Microsoft-Extensions-Configuration-AzureAppConfiguration-Refresh:
174+
A refresh operation failed while resolving a Key Vault reference.
175+
Key vault error. ErrorCode:'SecretNotFound' Key:'ExampleKey' Label:'ExampleLabel' Etag:'6LaqgBQM9C_Do2XyZa2gAIfj_ArpT52-xWwDSLb2hDo' SecretIdentifier:'https://examplevault.vault.azure.net/secrets/ExampleSecret'
176+
```
177+
178+
> [!NOTE]
179+
> Logging is available if you use version **6.0.0** or later of any of the following packages.
180+
> - `Microsoft.Extensions.Configuration.AzureAppConfiguration`
181+
> - `Microsoft.Azure.AppConfiguration.AspNetCore`
182+
> - `Microsoft.Azure.AppConfiguration.Functions.Worker`
183+
143184
## Clean up resources
144185

145186
[!INCLUDE [azure-app-configuration-cleanup](../../includes/azure-app-configuration-cleanup.md)]

0 commit comments

Comments
 (0)