Skip to content

Commit 6a2cecc

Browse files
authored
[AppService] Fix #13818 Subnet in different subscription (#14344)
1 parent 6b0d9dd commit 6a2cecc

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/Websites/Websites/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
- `Remove-AzAppServiceEnvironment`
2727
- `Get-AzAppServiceEnvironment`
2828
- `New-AzAppServiceEnvironmentInboundServices`
29+
* Add-AzWebAppAccessRestrictionRule: When using subnet from another subscription, -IgnoreMissingServiceEndpoint must be used. Descriptive error message added.
2930

3031
## Version 2.3.0
3132
* Added support for Importing a key vault certificate to WebApp.

src/Websites/Websites/Cmdlets/AccessRestriction/AddAzureWebAppAccessRestrictionRule.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ public override void ExecuteCmdlet()
187187
CheckDuplicateServiceEndpointRestriction(subnetResourceId, accessRestrictionList);
188188
if (!IgnoreMissingServiceEndpoint)
189189
{
190+
var subnetSubcriptionId = CmdletHelpers.GetSubscriptionIdFromResourceId(subnetResourceId);
191+
if (subnetSubcriptionId != DefaultContext.Subscription.Id)
192+
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.");
190193
var serviceEndpointServiceName = "Microsoft.Web";
191194
var serviceEndpointLocations = new List<string>() { "*" };
192195
NetworkClient.EnsureSubnetServiceEndpoint(subnetResourceId, serviceEndpointServiceName, serviceEndpointLocations);

src/Websites/Websites/Utilities/CmdletHelpers.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,11 @@ internal static string GetResourceGroupFromResourceId(string resourceId)
368368
return new ResourceIdentifier(resourceId).ResourceGroupName;
369369
}
370370

371+
internal static string GetSubscriptionIdFromResourceId(string resourceId)
372+
{
373+
return new ResourceIdentifier(resourceId).Subscription;
374+
}
375+
371376
internal static void ExtractWebAppPropertiesFromWebApp(Site webapp, out string resourceGroupName, out string webAppName, out string slot)
372377
{
373378
resourceGroupName = GetResourceGroupFromResourceId(webapp.Id);

0 commit comments

Comments
 (0)