Check the availability of a resource name. This API should be used to check the uniqueness of the name for support ticket creation for the selected subscription.
POST https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Support/checkNameAvailability?api-version=2024-04-01
URI Parameters
Name |
In |
Required |
Type |
Description |
subscriptionId
|
path |
True
|
string
uuid
|
The ID of the target subscription. The value must be an UUID.
|
api-version
|
query |
True
|
string
|
The API version to use for this operation.
|
Request Body
Name |
Required |
Type |
Description |
name
|
True
|
string
|
The resource name to validate.
|
type
|
True
|
Type
|
The type of resource.
|
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
Checks whether name is available for a subscription support ticket resource
Sample Request
POST https://management.azure.com/subscriptions/132d901f-189d-4381-9214-fe68e27e05a1/providers/Microsoft.Support/checkNameAvailability?api-version=2024-04-01
{
"name": "sampleName",
"type": "Microsoft.Support/supportTickets"
}
import com.azure.resourcemanager.support.models.CheckNameAvailabilityInput;
import com.azure.resourcemanager.support.models.Type;
/**
* Samples for SupportTickets CheckNameAvailability.
*/
public final class Main {
/*
* x-ms-original-file: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/
* CheckNameAvailabilityWithSubscription.json
*/
/**
* Sample code: Checks whether name is available for a subscription support ticket resource.
*
* @param manager Entry point to SupportManager.
*/
public static void checksWhetherNameIsAvailableForASubscriptionSupportTicketResource(
com.azure.resourcemanager.support.SupportManager manager) {
manager.supportTickets().checkNameAvailabilityWithResponse(
new CheckNameAvailabilityInput().withName("sampleName").withType(Type.MICROSOFT_SUPPORT_SUPPORT_TICKETS),
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
from typing import Any, IO, Union
from azure.identity import DefaultAzureCredential
from azure.mgmt.support import MicrosoftSupport
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-support
# USAGE
python check_name_availability_with_subscription.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = MicrosoftSupport(
credential=DefaultAzureCredential(),
subscription_id="132d901f-189d-4381-9214-fe68e27e05a1",
)
response = client.support_tickets.check_name_availability(
check_name_availability_input={"name": "sampleName", "type": "Microsoft.Support/supportTickets"},
)
print(response)
# x-ms-original-file: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CheckNameAvailabilityWithSubscription.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armsupport_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/support/armsupport"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/106483d9f698ac3b6c0d481ab0c5fab14152e21f/specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CheckNameAvailabilityWithSubscription.json
func ExampleTicketsClient_CheckNameAvailability() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armsupport.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewTicketsClient().CheckNameAvailability(ctx, armsupport.CheckNameAvailabilityInput{
Name: to.Ptr("sampleName"),
Type: to.Ptr(armsupport.TypeMicrosoftSupportSupportTickets),
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.CheckNameAvailabilityOutput = armsupport.CheckNameAvailabilityOutput{
// Message: to.Ptr("Name not available"),
// NameAvailable: to.Ptr(false),
// Reason: to.Ptr("Name is already in use"),
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { MicrosoftSupport } = require("@azure/arm-support");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Check the availability of a resource name. This API should be used to check the uniqueness of the name for support ticket creation for the selected subscription.
*
* @summary Check the availability of a resource name. This API should be used to check the uniqueness of the name for support ticket creation for the selected subscription.
* x-ms-original-file: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CheckNameAvailabilityWithSubscription.json
*/
async function checksWhetherNameIsAvailableForASubscriptionSupportTicketResource() {
const subscriptionId =
process.env["SUPPORT_SUBSCRIPTION_ID"] || "132d901f-189d-4381-9214-fe68e27e05a1";
const checkNameAvailabilityInput = {
name: "sampleName",
type: "Microsoft.Support/supportTickets",
};
const credential = new DefaultAzureCredential();
const client = new MicrosoftSupport(credential, subscriptionId);
const result = await client.supportTickets.checkNameAvailability(checkNameAvailabilityInput);
console.log(result);
}
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
{
"nameAvailable": false,
"reason": "Name is already in use",
"message": "Name not available"
}
Definitions
Input of CheckNameAvailability API.
Name |
Type |
Description |
name
|
string
|
The resource name to validate.
|
type
|
Type
|
The type of resource.
|
CheckNameAvailabilityOutput
Output of check name availability API.
Name |
Type |
Description |
message
|
string
|
The detailed error message describing why the name is not available.
|
nameAvailable
|
boolean
|
Indicates whether the name is available.
|
reason
|
string
|
The reason why the name is not available.
|
ErrorAdditionalInfo
The resource management error additional info.
Name |
Type |
Description |
info
|
object
|
The additional info.
|
type
|
string
|
The additional info type.
|
ErrorDetail
The error detail.
Name |
Type |
Description |
additionalInfo
|
ErrorAdditionalInfo[]
|
The error additional info.
|
code
|
string
|
The error code.
|
details
|
ErrorDetail[]
|
The error details.
|
message
|
string
|
The error message.
|
target
|
string
|
The error target.
|
ErrorResponse
Error response
Name |
Type |
Description |
error
|
ErrorDetail
|
The error object.
|
Type
The type of resource.
Name |
Type |
Description |
Microsoft.Support/communications
|
string
|
|
Microsoft.Support/supportTickets
|
string
|
|