Get custom hostnames under this subscription
GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Web/customhostnameSites?api-version=2024-04-01
With optional parameters:
GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Web/customhostnameSites?hostname={hostname}&api-version=2024-04-01
URI Parameters
Name |
In |
Required |
Type |
Description |
subscriptionId
|
path |
True
|
string
|
Your Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000).
|
api-version
|
query |
True
|
string
|
API Version
|
hostname
|
query |
|
string
|
Specific hostname
|
Responses
Security
azure_auth
Azure Active Directory OAuth2 Flow
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Name |
Description |
user_impersonation
|
impersonate your user account
|
Examples
Get custom hostnames under subscription
Sample request
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Web/customhostnameSites?api-version=2024-04-01
/**
* Samples for ResourceProvider ListCustomHostnameSites.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListCustomHostNameSites.json
*/
/**
* Sample code: Get custom hostnames under subscription.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void getCustomHostnamesUnderSubscription(com.azure.resourcemanager.AzureResourceManager azure) {
azure.webApps().manager().serviceClient().getResourceProviders().listCustomHostnameSites(null,
com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armappservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/appservice/armappservice/v4"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b5d78da207e9c5d8f82e95224039867271f47cdf/specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListCustomHostNameSites.json
func ExampleWebSiteManagementClient_NewListCustomHostNameSitesPager_getCustomHostnamesUnderSubscription() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armappservice.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewWebSiteManagementClient().NewListCustomHostNameSitesPager(&armappservice.WebSiteManagementClientListCustomHostNameSitesOptions{Hostname: nil})
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page.CustomHostnameSitesCollection = armappservice.CustomHostnameSitesCollection{
// Value: []*armappservice.CustomHostnameSites{
// {
// Name: to.Ptr("mywebapp.azurewebsites.net"),
// Type: to.Ptr("Microsoft.Web/customhostnameSites"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Web/customhostnameSites/mywebapp.azurewebsites.net"),
// Properties: &armappservice.CustomHostnameSitesProperties{
// CustomHostname: to.Ptr("mywebapp.azurewebsites.net"),
// Region: to.Ptr("West US"),
// SiteResourceIDs: []*armappservice.Identifier{
// {
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/westus-rg/providers/Microsoft.Web/sites/mywebapp"),
// }},
// },
// },
// {
// Name: to.Ptr("www.example.com"),
// Type: to.Ptr("Microsoft.Web/customhostnameSites"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Web/customhostnameSites/www.example.com"),
// Properties: &armappservice.CustomHostnameSitesProperties{
// CustomHostname: to.Ptr("www.example.com"),
// Region: to.Ptr("West US 2"),
// SiteResourceIDs: []*armappservice.Identifier{
// {
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/westus2-rg/providers/Microsoft.Web/sites/westus2app1"),
// },
// {
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/westus2-rg/providers/Microsoft.Web/sites/westus2app2"),
// },
// {
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/westus2-rg/providers/Microsoft.Web/sites/westus2app3"),
// }},
// },
// }},
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.AppService.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.AppService;
// Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListCustomHostNameSites.json
// this example is just showing the usage of "ListCustomHostNameSites" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this SubscriptionResource created on azure
// for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource
string subscriptionId = "00000000-0000-0000-0000-000000000000";
ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId);
SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId);
// invoke the operation and iterate over the result
await foreach (CustomHostnameSites item in subscriptionResource.GetCustomHostNameSitesAsync())
{
Console.WriteLine($"Succeeded: {item}");
}
Console.WriteLine("Succeeded");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Web/customhostnameSites/mywebapp.azurewebsites.net",
"name": "mywebapp.azurewebsites.net",
"type": "Microsoft.Web/customhostnameSites",
"properties": {
"customHostname": "mywebapp.azurewebsites.net",
"region": "West US",
"siteResourceIds": [
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/westus-rg/providers/Microsoft.Web/sites/mywebapp"
}
]
}
},
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Web/customhostnameSites/www.example.com",
"name": "www.example.com",
"type": "Microsoft.Web/customhostnameSites",
"properties": {
"customHostname": "www.example.com",
"region": "West US 2",
"siteResourceIds": [
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/westus2-rg/providers/Microsoft.Web/sites/westus2app1"
},
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/westus2-rg/providers/Microsoft.Web/sites/westus2app2"
},
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/westus2-rg/providers/Microsoft.Web/sites/westus2app3"
}
]
}
}
],
"nextLink": null
}
Get specific custom hostname under subscription
Sample request
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Web/customhostnameSites?hostname=www.example.com&api-version=2024-04-01
/**
* Samples for ResourceProvider ListCustomHostnameSites.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListCustomSpecificHostNameSites.json
*/
/**
* Sample code: Get specific custom hostname under subscription.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
getSpecificCustomHostnameUnderSubscription(com.azure.resourcemanager.AzureResourceManager azure) {
azure.webApps().manager().serviceClient().getResourceProviders().listCustomHostnameSites("www.example.com",
com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armappservice_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/appservice/armappservice/v4"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b5d78da207e9c5d8f82e95224039867271f47cdf/specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListCustomSpecificHostNameSites.json
func ExampleWebSiteManagementClient_NewListCustomHostNameSitesPager_getSpecificCustomHostnameUnderSubscription() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armappservice.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewWebSiteManagementClient().NewListCustomHostNameSitesPager(&armappservice.WebSiteManagementClientListCustomHostNameSitesOptions{Hostname: to.Ptr("www.example.com")})
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page.CustomHostnameSitesCollection = armappservice.CustomHostnameSitesCollection{
// Value: []*armappservice.CustomHostnameSites{
// {
// Name: to.Ptr("www.example.com"),
// Type: to.Ptr("Microsoft.Web/customhostnameSites"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Web/customhostnameSites/www.example.com"),
// Properties: &armappservice.CustomHostnameSitesProperties{
// CustomHostname: to.Ptr("www.example.com"),
// Region: to.Ptr("West US 2"),
// SiteResourceIDs: []*armappservice.Identifier{
// {
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/westus2-rg/providers/Microsoft.Web/sites/westus2app1"),
// },
// {
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/westus2-rg/providers/Microsoft.Web/sites/westus2app2"),
// },
// {
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/westus2-rg/providers/Microsoft.Web/sites/westus2app3"),
// }},
// },
// }},
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.AppService.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.AppService;
// Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListCustomSpecificHostNameSites.json
// this example is just showing the usage of "ListCustomHostNameSites" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this SubscriptionResource created on azure
// for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource
string subscriptionId = "00000000-0000-0000-0000-000000000000";
ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId);
SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId);
// invoke the operation and iterate over the result
string hostname = "www.example.com";
await foreach (CustomHostnameSites item in subscriptionResource.GetCustomHostNameSitesAsync(hostname: hostname))
{
Console.WriteLine($"Succeeded: {item}");
}
Console.WriteLine("Succeeded");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Web/customhostnameSites/www.example.com",
"name": "www.example.com",
"type": "Microsoft.Web/customhostnameSites",
"properties": {
"customHostname": "www.example.com",
"region": "West US 2",
"siteResourceIds": [
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/westus2-rg/providers/Microsoft.Web/sites/westus2app1"
},
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/westus2-rg/providers/Microsoft.Web/sites/westus2app2"
},
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/westus2-rg/providers/Microsoft.Web/sites/westus2app3"
}
]
}
}
],
"nextLink": null
}
Definitions
CustomHostnameSites
A hostname and its assigned sites
Name |
Type |
Description |
id
|
string
|
Resource Id.
|
kind
|
string
|
Kind of resource.
|
name
|
string
|
Resource Name.
|
properties.customHostname
|
string
|
|
properties.region
|
string
|
|
properties.siteResourceIds
|
Identifier[]
|
A domain specific resource identifier.
|
type
|
string
|
Resource type.
|
CustomHostnameSitesCollection
Collection of custom hostname sites
Name |
Type |
Description |
nextLink
|
string
|
Link to next page of resources.
|
value
|
CustomHostnameSites[]
|
Collection of resources.
|
DefaultErrorResponse
App Service error response.
Name |
Type |
Description |
error
|
Error
|
Error model.
|
Details
Name |
Type |
Description |
code
|
string
|
Standardized string to programmatically identify the error.
|
message
|
string
|
Detailed error description and debugging information.
|
target
|
string
|
Detailed error description and debugging information.
|
Error
Error model.
Name |
Type |
Description |
code
|
string
|
Standardized string to programmatically identify the error.
|
details
|
Details[]
|
Detailed errors.
|
innererror
|
string
|
More information to debug error.
|
message
|
string
|
Detailed error description and debugging information.
|
target
|
string
|
Detailed error description and debugging information.
|
Identifier
A domain specific resource identifier.
Name |
Type |
Description |
id
|
string
|
Resource Id.
|
kind
|
string
|
Kind of resource.
|
name
|
string
|
Resource Name.
|
properties.id
|
string
|
String representation of the identity.
|
type
|
string
|
Resource type.
|