-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply new consumption defaults in AzureStorageDurabilityProvider (#1706)
- Loading branch information
1 parent
6fd65a8
commit 85d0642
Showing
19 changed files
with
467 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
<-- Please include a link to your pending docs PR below. https://docs.microsoft.com/en-us/azure/azure-functions/durable ([private docs repo for Microsoft employees](http://github.com/MicrosoftDocs/azure-docs-pr)). | ||
<!-- Please include a link to your pending docs PR below. https://docs.microsoft.com/en-us/azure/azure-functions/durable ([private docs repo for Microsoft employees](http://github.com/MicrosoftDocs/azure-docs-pr)). | ||
Your code PR should not be merged until your docs PR has been signed off. --> | ||
https://github.com/MicrosoftDocs/azure-docs-pr/pull/149980 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
|
||
Improved concurrency defaults for the App Service Consumption plan (https://github.com/Azure/azure-functions-durable-extension/pull/1706) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/WebJobs.Extensions.DurableTask/DefaultPlatformInformationProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
using System; | ||
|
||
namespace Microsoft.Azure.WebJobs.Extensions.DurableTask | ||
{ | ||
/// <summary> | ||
/// Provides information about the enviroment (OS, app service plan, user-facing PL) | ||
/// using the DI-injected INameResolver. | ||
/// </summary> | ||
#pragma warning disable CS0612 // Type or member is obsolete | ||
internal class DefaultPlatformInformationProvider : IPlatformInformationService | ||
#pragma warning restore CS0612 // Type or member is obsolete | ||
{ | ||
private readonly INameResolver nameResolver; | ||
|
||
public DefaultPlatformInformationProvider(INameResolver nameResolver) | ||
{ | ||
this.nameResolver = nameResolver; | ||
} | ||
|
||
public bool InConsumption() | ||
{ | ||
return this.InLinuxConsumption() | this.InWindowsConsumption(); | ||
} | ||
|
||
public bool InWindowsConsumption() | ||
{ | ||
string value = this.nameResolver.Resolve("WEBSITE_SKU"); | ||
return string.Equals(value, "Dynamic", StringComparison.OrdinalIgnoreCase); | ||
} | ||
|
||
public bool InLinuxConsumption() | ||
{ | ||
string containerName = this.GetContainerName(); | ||
string azureWebsiteInstanceId = this.nameResolver.Resolve("WEBSITE_INSTANCE_ID"); | ||
bool inAppService = !string.IsNullOrEmpty(azureWebsiteInstanceId); | ||
bool inLinuxConsumption = !inAppService && !string.IsNullOrEmpty(containerName); | ||
return inLinuxConsumption; | ||
} | ||
|
||
public bool InLinuxAppService() | ||
{ | ||
string azureWebsiteInstanceId = this.nameResolver.Resolve("WEBSITE_INSTANCE_ID"); | ||
string functionsLogsMountPath = this.nameResolver.Resolve("FUNCTIONS_LOGS_MOUNT_PATH"); | ||
bool inAppService = !string.IsNullOrEmpty(azureWebsiteInstanceId); | ||
bool inLinuxDedicated = inAppService && !string.IsNullOrEmpty(functionsLogsMountPath); | ||
return inLinuxDedicated; | ||
} | ||
|
||
public string GetLinuxTenant() | ||
{ | ||
return this.nameResolver.Resolve("WEBSITE_STAMP_DEPLOYMENT_ID"); | ||
} | ||
|
||
public string GetLinuxStampName() | ||
{ | ||
return this.nameResolver.Resolve("WEBSITE_HOME_STAMPNAME"); | ||
} | ||
|
||
public string GetContainerName() | ||
{ | ||
return this.nameResolver.Resolve("CONTAINER_NAME"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/WebJobs.Extensions.DurableTask/IPlatformInformationService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
using System; | ||
|
||
namespace Microsoft.Azure.WebJobs.Extensions.DurableTask | ||
{ | ||
/// <summary> | ||
/// Interface for accessing the AppService plan information, | ||
/// the OS, and user-facing PL. | ||
/// | ||
/// Note: The functionality is currently limited, but will grow | ||
/// along with the pursuit of more platform-specific defaults. | ||
/// </summary> | ||
[Obsolete] | ||
public interface IPlatformInformationService | ||
{ | ||
/// <summary> | ||
/// Determines if the application is running on a Consumption plan, | ||
/// irrespective of OS. | ||
/// </summary> | ||
/// <returns>True if running in Consumption. Otherwise, False.</returns> | ||
bool InConsumption(); | ||
|
||
/// <summary> | ||
/// Determines if the application is running in a Linux Consumption plan. | ||
/// </summary> | ||
/// <returns>True if running in Linux Consumption. Otherwise, False.</returns> | ||
bool InLinuxConsumption(); | ||
|
||
/// <summary> | ||
/// Determines if the application is running in a Windows Consumption plan. | ||
/// </summary> | ||
/// <returns>True if running in Linux Consumption. Otherwise, False.</returns> | ||
bool InWindowsConsumption(); | ||
|
||
/// <summary> | ||
/// Determines if the application is running in a Linux AppService plan. | ||
/// </summary> | ||
/// <returns>True if running in Linux AppService. Otherwise, False.</returns> | ||
bool InLinuxAppService(); | ||
|
||
/// <summary> | ||
/// Returns the application tenant when running on linux. | ||
/// </summary> | ||
/// <returns>The application tenant.</returns> | ||
string GetLinuxTenant(); | ||
|
||
/// <summary> | ||
/// Returns the application stamp name when running on linux. | ||
/// </summary> | ||
/// <returns>The application stamp name.</returns> | ||
string GetLinuxStampName(); | ||
|
||
/// <summary> | ||
/// Returns the application container name when running on linux. | ||
/// </summary> | ||
/// <returns>The application container name.</returns> | ||
string GetContainerName(); | ||
} | ||
} |
Oops, something went wrong.