Skip to content

[AppService] Fix #13818 Subnet in different subscription #14344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Websites/Websites/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- `Remove-AzAppServiceEnvironment`
- `Get-AzAppServiceEnvironment`
- `New-AzAppServiceEnvironmentInboundServices`
* Add-AzWebAppAccessRestrictionRule: When using subnet from another subscription, -IgnoreMissingServiceEndpoint must be used. Descriptive error message added.

## Version 2.3.0
* Added support for Importing a key vault certificate to WebApp.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ public override void ExecuteCmdlet()
CheckDuplicateServiceEndpointRestriction(subnetResourceId, accessRestrictionList);
if (!IgnoreMissingServiceEndpoint)
{
var subnetSubcriptionId = CmdletHelpers.GetSubscriptionIdFromResourceId(subnetResourceId);
if (subnetSubcriptionId != DefaultContext.Subscription.Id)
throw new Exception("Service endpoint cannot be validated. Subnet is in another subscription. Use -IgnoreMissingServiceEndpoint and manually verify that 'Microsoft.Web' service endpoint is enabled on the subnet.");
var serviceEndpointServiceName = "Microsoft.Web";
var serviceEndpointLocations = new List<string>() { "*" };
NetworkClient.EnsureSubnetServiceEndpoint(subnetResourceId, serviceEndpointServiceName, serviceEndpointLocations);
Expand Down
5 changes: 5 additions & 0 deletions src/Websites/Websites/Utilities/CmdletHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,11 @@ internal static string GetResourceGroupFromResourceId(string resourceId)
return new ResourceIdentifier(resourceId).ResourceGroupName;
}

internal static string GetSubscriptionIdFromResourceId(string resourceId)
{
return new ResourceIdentifier(resourceId).Subscription;
}

internal static void ExtractWebAppPropertiesFromWebApp(Site webapp, out string resourceGroupName, out string webAppName, out string slot)
{
resourceGroupName = GetResourceGroupFromResourceId(webapp.Id);
Expand Down