Skip to content
Open
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
7 changes: 4 additions & 3 deletions curl/management.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,16 @@ To create a new resource, run the following command.
- Replace `<resource type>` with the resource type of the new resource (for example, "Text Translation").
- Replace `<location>` with the location of the new resource (for example, "westus" or "global").
- Replace `<sku name>` with the subscription tier of the new resource (for example, "F0").
- Replace `<subdomain name>` with a custom subdomain name (for example, "my-text-translation-resource"). This is optional.
- Replace `<token>` with your Azure access token.

```
curl https://management.azure.com/subscriptions/<subscription ID>/resourceGroups/<resource group name>/providers/Microsoft.CognitiveServices/accounts/<account name>?api-version=2017-04-18 -X PUT -H "Content-Type: application/json" -d "{ 'kind' : '<resource type>', 'location' : '<location>', 'sku' : { 'name' : '<sku name>' }}" -H "Authorization: Bearer <token>"
curl https://management.azure.com/subscriptions/<subscription ID>/resourceGroups/<resource group name>/providers/Microsoft.CognitiveServices/accounts/<account name>?api-version=2017-04-18 -X PUT -H "Content-Type: application/json" -d "{ 'kind' : '<resource type>', 'location' : '<location>', 'sku' : { 'name' : '<sku name>' }, 'properties' : { 'customSubDomainName' : '<subdomain name>' }}" -H "Authorization: Bearer <token>"
```

For example, the following creates a resource with kind Text Translation, SKU F0 (free tier), location global. You will still need to replace `<subscription ID>`, `<resource group name>`, `<account name>`, and `<token>`.
For example, the following creates a resource with kind Text Translation, SKU F0 (free tier), location global. You will still need to replace `<subscription ID>`, `<resource group name>`, `<account name>`, `<subdomain name>`, and `<token>`.
```
curl https://management.azure.com/subscriptions/<subscription ID>/resourceGroups/<resource group name>/providers/Microsoft.CognitiveServices/accounts/<account name>?api-version=2017-04-18 -X PUT -H "Content-Type: application/json" -d "{ 'kind' : 'TextTranslation', 'location' : 'Global', 'sku' : { 'name' : 'F0' }}" -H "Authorization: Bearer <token>"
curl https://management.azure.com/subscriptions/<subscription ID>/resourceGroups/<resource group name>/providers/Microsoft.CognitiveServices/accounts/<account name>?api-version=2017-04-18 -X PUT -H "Content-Type: application/json" -d "{ 'kind' : 'TextTranslation', 'location' : 'Global', 'sku' : { 'name' : 'F0' }, 'properties' : { 'customSubDomainName' : '<subdomain name>' }}" -H "Authorization: Bearer <token>"
```

For more information see:
Expand Down
16 changes: 13 additions & 3 deletions powershell/management.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@

# The name of the Azure resource group in which you want to create the resource.
# You can find resource groups in the Azure Dashboard under Home > Resource groups.
$resource_group_name = "TODO_REPLACE";
$resource_group_name = "PASTE_YOUR_RESOURCE_GROUP_NAME_HERE";

# The name of the resource you want to create.
# Note Azure resources are also sometimes referred to as accounts.
$resource_name = "PASTE_YOUR_RESOURCE_NAME_HERE";

# The name of the custom subdomain to use when you create the resource. This is optional.
# For example, if you create a Bing Search v7 resource with the custom subdomain name 'my-search-resource',
# your resource would have the endpoint https://my-search-resource.cognitiveservices.azure.com/.
# Note not all Cognitive Services allow custom subdomain names.
$subdomain_name = "PASTE_YOUR_SUBDOMAIN_NAME_HERE";

echo "Connecting to Azure account."
Connect-AzAccount
Expand All @@ -28,11 +38,11 @@ Get-AzCognitiveServicesAccount -ResourceGroupName $resource_group_name
# For more information see:
# https://docs.microsoft.com/en-us/powershell/module/az.cognitiveservices/new-azcognitiveservicesaccount?view=azps-3.3.0
echo "Creating a resource with kind Text Translation, SKU F0 (free tier), location global."
$result = New-AzCognitiveServicesAccount -ResourceGroupName $resource_group_name -Name "test_resource" -Type "TextTranslation" -SkuName "F0" -Location "Global"
$result = New-AzCognitiveServicesAccount -ResourceGroupName $resource_group_name -Name $resource_name -Type "TextTranslation" -SkuName "F0" -Location "Global" -CustomSubdomainName $subdomain_name
echo "Result:"
echo $result

# For more information see:
# https://docs.microsoft.com/en-us/powershell/module/az.cognitiveservices/remove-azcognitiveservicesaccount?view=azps-3.3.0
echo "Removing resource."
Remove-AzCognitiveServicesAccount -ResourceGroupName $resource_group_name -Name "test_resource"
Remove-AzCognitiveServicesAccount -ResourceGroupName $resource_group_name -Name $resource_name