Проверяет доступность имени.
Проверяет, является ли имя CommunicationService допустимым и еще не используется.
POST https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Communication/checkNameAvailability?api-version=2023-03-31
Параметры URI
Имя |
В |
Обязательно |
Тип |
Описание |
subscriptionId
|
path |
True
|
string
uuid
|
Идентификатор целевой подписки. Значение должно быть UUID.
|
api-version
|
query |
True
|
string
|
Версия API, используемая для данной операции.
|
Текст запроса
Имя |
Обязательно |
Тип |
Описание |
name
|
True
|
string
|
Имя ресурса, для которого необходимо проверить доступность.
|
type
|
True
|
string
|
Тип ресурса.
|
Ответы
Примеры
Check name availability available
Sample Request
POST https://management.azure.com/subscriptions/11112222-3333-4444-5555-666677778888/providers/Microsoft.Communication/checkNameAvailability?api-version=2023-03-31
{
"type": "Microsoft.Communication/CommunicationServices",
"name": "MyCommunicationService"
}
import com.azure.resourcemanager.communication.models.NameAvailabilityParameters;
/** Samples for CommunicationServices CheckNameAvailability. */
public final class Main {
/*
* x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/stable/2023-03-31/examples/communicationServices/checkNameAvailabilityAvailable.json
*/
/**
* Sample code: Check name availability available.
*
* @param manager Entry point to CommunicationManager.
*/
public static void checkNameAvailabilityAvailable(
com.azure.resourcemanager.communication.CommunicationManager manager) {
manager
.communicationServices()
.checkNameAvailabilityWithResponse(
new NameAvailabilityParameters()
.withName("MyCommunicationService")
.withType("Microsoft.Communication/CommunicationServices"),
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 azure.identity import DefaultAzureCredential
from azure.mgmt.communication import CommunicationServiceManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-communication
# USAGE
python check_name_availability_available.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 = CommunicationServiceManagementClient(
credential=DefaultAzureCredential(),
subscription_id="11112222-3333-4444-5555-666677778888",
)
response = client.communication_services.check_name_availability(
name_availability_parameters={
"name": "MyCommunicationService",
"type": "Microsoft.Communication/CommunicationServices",
},
)
print(response)
# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/stable/2023-03-31/examples/communicationServices/checkNameAvailabilityAvailable.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 armcommunication_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/communication/armcommunication/v2"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/06042d4ffed6a1ea8319c39cd07ea21efe5d49f7/specification/communication/resource-manager/Microsoft.Communication/stable/2023-03-31/examples/communicationServices/checkNameAvailabilityAvailable.json
func ExampleServicesClient_CheckNameAvailability_checkNameAvailabilityAvailable() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcommunication.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewServicesClient().CheckNameAvailability(ctx, armcommunication.NameAvailabilityParameters{
Name: to.Ptr("MyCommunicationService"),
Type: to.Ptr("Microsoft.Communication/CommunicationServices"),
}, 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.CheckNameAvailabilityResponse = armcommunication.CheckNameAvailabilityResponse{
// Message: to.Ptr("Requested name is available for the requested type"),
// NameAvailable: to.Ptr(true),
// Reason: to.Ptr(armcommunication.CheckNameAvailabilityReason("NameAvailable")),
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { CommunicationServiceManagementClient } = require("@azure/arm-communication");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Checks that the CommunicationService name is valid and is not already in use.
*
* @summary Checks that the CommunicationService name is valid and is not already in use.
* x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/stable/2023-03-31/examples/communicationServices/checkNameAvailabilityAvailable.json
*/
async function checkNameAvailabilityAvailable() {
const subscriptionId =
process.env["COMMUNICATION_SUBSCRIPTION_ID"] || "11112222-3333-4444-5555-666677778888";
const nameAvailabilityParameters = {
name: "MyCommunicationService",
type: "Microsoft.Communication/CommunicationServices",
};
const credential = new DefaultAzureCredential();
const client = new CommunicationServiceManagementClient(credential, subscriptionId);
const result = await client.communicationServices.checkNameAvailability(
nameAvailabilityParameters
);
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
using System;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Communication;
using Azure.ResourceManager.Communication.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-03-31/examples/communicationServices/checkNameAvailabilityAvailable.json
// this example is just showing the usage of "CommunicationServices_CheckNameAvailability" 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 = "11112222-3333-4444-5555-666677778888";
ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId);
SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId);
// invoke the operation
CommunicationServiceNameAvailabilityContent content = new CommunicationServiceNameAvailabilityContent()
{
Name = "MyCommunicationService",
ResourceType = new ResourceType("Microsoft.Communication/CommunicationServices"),
};
CommunicationNameAvailabilityResult result = await subscriptionResource.CheckCommunicationNameAvailabilityAsync(content);
Console.WriteLine($"Succeeded: {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": true,
"reason": "NameAvailable",
"message": "Requested name is available for the requested type"
}
Check name availability unavailable
Sample Request
POST https://management.azure.com/subscriptions/11112222-3333-4444-5555-666677778888/providers/Microsoft.Communication/checkNameAvailability?api-version=2023-03-31
{
"type": "Microsoft.Communication/CommunicationServices",
"name": "MyCommunicationService"
}
import com.azure.resourcemanager.communication.models.NameAvailabilityParameters;
/** Samples for CommunicationServices CheckNameAvailability. */
public final class Main {
/*
* x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/stable/2023-03-31/examples/communicationServices/checkNameAvailabilityUnavailable.json
*/
/**
* Sample code: Check name availability unavailable.
*
* @param manager Entry point to CommunicationManager.
*/
public static void checkNameAvailabilityUnavailable(
com.azure.resourcemanager.communication.CommunicationManager manager) {
manager
.communicationServices()
.checkNameAvailabilityWithResponse(
new NameAvailabilityParameters()
.withName("MyCommunicationService")
.withType("Microsoft.Communication/CommunicationServices"),
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 azure.identity import DefaultAzureCredential
from azure.mgmt.communication import CommunicationServiceManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-communication
# USAGE
python check_name_availability_unavailable.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 = CommunicationServiceManagementClient(
credential=DefaultAzureCredential(),
subscription_id="11112222-3333-4444-5555-666677778888",
)
response = client.communication_services.check_name_availability(
name_availability_parameters={
"name": "MyCommunicationService",
"type": "Microsoft.Communication/CommunicationServices",
},
)
print(response)
# x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/stable/2023-03-31/examples/communicationServices/checkNameAvailabilityUnavailable.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 armcommunication_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/communication/armcommunication/v2"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/06042d4ffed6a1ea8319c39cd07ea21efe5d49f7/specification/communication/resource-manager/Microsoft.Communication/stable/2023-03-31/examples/communicationServices/checkNameAvailabilityUnavailable.json
func ExampleServicesClient_CheckNameAvailability_checkNameAvailabilityUnavailable() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcommunication.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewServicesClient().CheckNameAvailability(ctx, armcommunication.NameAvailabilityParameters{
Name: to.Ptr("MyCommunicationService"),
Type: to.Ptr("Microsoft.Communication/CommunicationServices"),
}, 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.CheckNameAvailabilityResponse = armcommunication.CheckNameAvailabilityResponse{
// Message: to.Ptr("Requested name is unavailable for the requested type"),
// NameAvailable: to.Ptr(false),
// Reason: to.Ptr(armcommunication.CheckNameAvailabilityReasonAlreadyExists),
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { CommunicationServiceManagementClient } = require("@azure/arm-communication");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Checks that the CommunicationService name is valid and is not already in use.
*
* @summary Checks that the CommunicationService name is valid and is not already in use.
* x-ms-original-file: specification/communication/resource-manager/Microsoft.Communication/stable/2023-03-31/examples/communicationServices/checkNameAvailabilityUnavailable.json
*/
async function checkNameAvailabilityUnavailable() {
const subscriptionId =
process.env["COMMUNICATION_SUBSCRIPTION_ID"] || "11112222-3333-4444-5555-666677778888";
const nameAvailabilityParameters = {
name: "MyCommunicationService",
type: "Microsoft.Communication/CommunicationServices",
};
const credential = new DefaultAzureCredential();
const client = new CommunicationServiceManagementClient(credential, subscriptionId);
const result = await client.communicationServices.checkNameAvailability(
nameAvailabilityParameters
);
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
using System;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Communication;
using Azure.ResourceManager.Communication.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-03-31/examples/communicationServices/checkNameAvailabilityUnavailable.json
// this example is just showing the usage of "CommunicationServices_CheckNameAvailability" 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 = "11112222-3333-4444-5555-666677778888";
ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId);
SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId);
// invoke the operation
CommunicationServiceNameAvailabilityContent content = new CommunicationServiceNameAvailabilityContent()
{
Name = "MyCommunicationService",
ResourceType = new ResourceType("Microsoft.Communication/CommunicationServices"),
};
CommunicationNameAvailabilityResult result = await subscriptionResource.CheckCommunicationNameAvailabilityAsync(content);
Console.WriteLine($"Succeeded: {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": "AlreadyExists",
"message": "Requested name is unavailable for the requested type"
}
Определения
CheckNameAvailabilityReason
Причина, по которой данное имя недоступно.
Имя |
Тип |
Описание |
AlreadyExists
|
string
|
|
Invalid
|
string
|
|
CheckNameAvailabilityResponse
Результат доступности проверка.
Имя |
Тип |
Описание |
message
|
string
|
Подробная причина, по которой данное имя доступно.
|
nameAvailable
|
boolean
|
Указывает, доступно ли имя ресурса.
|
reason
|
CheckNameAvailabilityReason
|
Причина, по которой данное имя недоступно.
|
ErrorAdditionalInfo
Дополнительные сведения об ошибке управления ресурсами.
Имя |
Тип |
Описание |
info
|
object
|
Дополнительные сведения.
|
type
|
string
|
Тип дополнительных сведений.
|
ErrorDetail
Сведения об ошибке.
Имя |
Тип |
Описание |
additionalInfo
|
ErrorAdditionalInfo[]
|
Дополнительные сведения об ошибке.
|
code
|
string
|
Код ошибки.
|
details
|
ErrorDetail[]
|
Сведения об ошибке.
|
message
|
string
|
Сообщение об ошибке.
|
target
|
string
|
Целевой объект ошибки.
|
ErrorResponse
Сообщение об ошибке
NameAvailabilityParameters
Data POST-ed to the nameAvailability action
Имя |
Тип |
Описание |
name
|
string
|
Имя ресурса, для которого необходимо проверить доступность.
|
type
|
string
|
Тип ресурса.
|