Creates a new certificate inside the specified account.
Warning: This operation is deprecated and will be removed after February, 2024. Please use the Azure KeyVault Extension instead.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/certificates/{certificateName}?api-version=2024-02-01
URI Parameters
Name |
In |
Required |
Type |
Description |
accountName
|
path |
True
|
string
|
The name of the Batch account.
Regex pattern: ^[a-zA-Z0-9]+$
|
certificateName
|
path |
True
|
string
|
The identifier for the certificate. This must be made up of algorithm and thumbprint separated by a dash, and must match the certificate data in the request. For example SHA1-a3d1c5.
Regex pattern: ^[\w]+-[\w]+$
|
resourceGroupName
|
path |
True
|
string
|
The name of the resource group that contains the Batch account.
|
subscriptionId
|
path |
True
|
string
|
The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000)
|
api-version
|
query |
True
|
string
|
The API version to be used with the HTTP request.
|
Name |
Required |
Type |
Description |
If-Match
|
|
string
|
The entity state (ETag) version of the certificate to update. A value of "*" can be used to apply the operation only if the certificate already exists. If omitted, this operation will always be applied.
|
If-None-Match
|
|
string
|
Set to '*' to allow a new certificate to be created, but to prevent updating an existing certificate. Other values will be ignored.
|
Request Body
Name |
Required |
Type |
Description |
properties.data
|
True
|
string
|
The base64-encoded contents of the certificate.
The maximum size is 10KB.
|
properties.format
|
|
CertificateFormat
|
The format of the certificate - either Pfx or Cer. If omitted, the default is Pfx.
|
properties.password
|
|
string
|
The password to access the certificate's private key.
This must not be specified if the certificate format is Cer.
|
properties.thumbprint
|
|
string
|
The thumbprint of the certificate.
This must match the thumbprint from the name.
|
properties.thumbprintAlgorithm
|
|
string
|
The algorithm of the certificate thumbprint.
This must match the first portion of the certificate name. Currently required to be 'SHA1'.
|
Responses
Name |
Type |
Description |
200 OK
|
Certificate
|
The operation was successful. The response contains the certificate entity.
Headers
ETag: string
|
Other Status Codes
|
CloudError
|
Error response describing why the operation failed.
|
Security
azure_auth
Microsoft Entra OAuth 2.0 auth code flow
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Name |
Description |
user_impersonation
|
impersonate your user account
|
Examples
CreateCertificate - Full
Sample Request
PUT https://management.azure.com/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/certificates/sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e?api-version=2024-02-01
{
"properties": {
"thumbprintAlgorithm": "sha1",
"thumbprint": "0a0e4f50d51beadeac1d35afc5116098e7902e6e",
"data": "MIIJsgIBAzCCCW4GCSqGSIb3DQE...",
"password": "<ExamplePassword>",
"format": "Pfx"
}
}
import com.azure.resourcemanager.batch.models.CertificateFormat;
/**
* Samples for Certificate Create.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/CertificateCreate_Full.json
*/
/**
* Sample code: CreateCertificate - Full.
*
* @param manager Entry point to BatchManager.
*/
public static void createCertificateFull(com.azure.resourcemanager.batch.BatchManager manager) {
manager.certificates().define("sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e")
.withExistingBatchAccount("default-azurebatch-japaneast", "sampleacct").withPassword("<ExamplePassword>")
.withThumbprintAlgorithm("sha1").withThumbprint("0a0e4f50d51beadeac1d35afc5116098e7902e6e")
.withFormat(CertificateFormat.PFX).create();
}
}
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.batch import BatchManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-batch
# USAGE
python certificate_create_full.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 = BatchManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.certificate.create(
resource_group_name="default-azurebatch-japaneast",
account_name="sampleacct",
certificate_name="sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e",
parameters={
"properties": {
"data": "MIIJsgIBAzCCCW4GCSqGSIb3DQE...",
"format": "Pfx",
"password": "<ExamplePassword>",
"thumbprint": "0a0e4f50d51beadeac1d35afc5116098e7902e6e",
"thumbprintAlgorithm": "sha1",
}
},
)
print(response)
# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/CertificateCreate_Full.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 armbatch_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/batch/armbatch/v2"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/cf5ad1932d00c7d15497705ad6b71171d3d68b1e/specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/CertificateCreate_Full.json
func ExampleCertificateClient_Create_createCertificateFull() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armbatch.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewCertificateClient().Create(ctx, "default-azurebatch-japaneast", "sampleacct", "sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e", armbatch.CertificateCreateOrUpdateParameters{
Properties: &armbatch.CertificateCreateOrUpdateProperties{
Format: to.Ptr(armbatch.CertificateFormatPfx),
Thumbprint: to.Ptr("0a0e4f50d51beadeac1d35afc5116098e7902e6e"),
ThumbprintAlgorithm: to.Ptr("sha1"),
Data: to.Ptr("MIIJsgIBAzCCCW4GCSqGSIb3DQE..."),
Password: to.Ptr("<ExamplePassword>"),
},
}, &armbatch.CertificateClientCreateOptions{IfMatch: nil,
IfNoneMatch: 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.Certificate = armbatch.Certificate{
// Name: to.Ptr("sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e"),
// Type: to.Ptr("Microsoft.Batch/batchAccounts/certificates"),
// Etag: to.Ptr("W/\"0x8D4EDD5118668F7\""),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/samplecct/certificates/sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e"),
// Properties: &armbatch.CertificateProperties{
// Format: to.Ptr(armbatch.CertificateFormatPfx),
// Thumbprint: to.Ptr("0a0e4f50d51beadeac1d35afc5116098e7902e6e"),
// ThumbprintAlgorithm: to.Ptr("sha1"),
// ProvisioningState: to.Ptr(armbatch.CertificateProvisioningStateSucceeded),
// ProvisioningStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-07-21T01:47:38.442Z"); return t}()),
// PublicData: to.Ptr("MIICrjCCAZagAwI..."),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { BatchManagementClient } = require("@azure/arm-batch");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Warning: This operation is deprecated and will be removed after February, 2024. Please use the [Azure KeyVault Extension](https://learn.microsoft.com/azure/batch/batch-certificate-migration-guide) instead.
*
* @summary Warning: This operation is deprecated and will be removed after February, 2024. Please use the [Azure KeyVault Extension](https://learn.microsoft.com/azure/batch/batch-certificate-migration-guide) instead.
* x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/CertificateCreate_Full.json
*/
async function createCertificateFull() {
const subscriptionId = process.env["BATCH_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["BATCH_RESOURCE_GROUP"] || "default-azurebatch-japaneast";
const accountName = "sampleacct";
const certificateName = "sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e";
const parameters = {
format: "Pfx",
data: "MIIJsgIBAzCCCW4GCSqGSIb3DQE...",
password: "<ExamplePassword>",
thumbprint: "0a0e4f50d51beadeac1d35afc5116098e7902e6e",
thumbprintAlgorithm: "sha1",
};
const credential = new DefaultAzureCredential();
const client = new BatchManagementClient(credential, subscriptionId);
const result = await client.certificateOperations.create(
resourceGroupName,
accountName,
certificateName,
parameters,
);
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.Batch;
using Azure.ResourceManager.Batch.Models;
// Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/CertificateCreate_Full.json
// this example is just showing the usage of "Certificate_Create" 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 BatchAccountResource created on azure
// for more information of creating BatchAccountResource, please refer to the document of BatchAccountResource
string subscriptionId = "subid";
string resourceGroupName = "default-azurebatch-japaneast";
string accountName = "sampleacct";
ResourceIdentifier batchAccountResourceId = BatchAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName);
BatchAccountResource batchAccount = client.GetBatchAccountResource(batchAccountResourceId);
// get the collection of this BatchAccountCertificateResource
BatchAccountCertificateCollection collection = batchAccount.GetBatchAccountCertificates();
// invoke the operation
string certificateName = "sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e";
BatchAccountCertificateCreateOrUpdateContent content = new BatchAccountCertificateCreateOrUpdateContent()
{
ThumbprintAlgorithm = "sha1",
ThumbprintString = "0a0e4f50d51beadeac1d35afc5116098e7902e6e",
Format = BatchAccountCertificateFormat.Pfx,
Data = BinaryData.FromString("MIIJsgIBAzCCCW4GCSqGSIb3DQE..."),
Password = "<ExamplePassword>",
};
ArmOperation<BatchAccountCertificateResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateName, content);
BatchAccountCertificateResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
BatchAccountCertificateData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
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
ETag: W/"0x8D4EDD5118668F7"
{
"id": "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/samplecct/certificates/sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e",
"name": "sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e",
"type": "Microsoft.Batch/batchAccounts/certificates",
"etag": "W/\"0x8D4EDD5118668F7\"",
"properties": {
"thumbprintAlgorithm": "sha1",
"thumbprint": "0a0e4f50d51beadeac1d35afc5116098e7902e6e",
"provisioningState": "Succeeded",
"provisioningStateTransitionTime": "2017-07-21T01:47:38.4420202Z",
"format": "Pfx",
"publicData": "MIICrjCCAZagAwI..."
}
}
CreateCertificate - Minimal Cer
Sample Request
PUT https://management.azure.com/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/certificates/sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e?api-version=2024-02-01
{
"properties": {
"data": "MIICrjCCAZagAwI...",
"format": "Cer"
}
}
import com.azure.resourcemanager.batch.models.CertificateFormat;
/**
* Samples for Certificate Create.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/CertificateCreate_MinimalCer.json
*/
/**
* Sample code: CreateCertificate - Minimal Cer.
*
* @param manager Entry point to BatchManager.
*/
public static void createCertificateMinimalCer(com.azure.resourcemanager.batch.BatchManager manager) {
manager.certificates().define("sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e")
.withExistingBatchAccount("default-azurebatch-japaneast", "sampleacct").withFormat(CertificateFormat.CER)
.create();
}
}
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.batch import BatchManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-batch
# USAGE
python certificate_create_minimal_cer.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 = BatchManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.certificate.create(
resource_group_name="default-azurebatch-japaneast",
account_name="sampleacct",
certificate_name="sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e",
parameters={"properties": {"data": "MIICrjCCAZagAwI...", "format": "Cer"}},
)
print(response)
# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/CertificateCreate_MinimalCer.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 armbatch_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/batch/armbatch/v2"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/cf5ad1932d00c7d15497705ad6b71171d3d68b1e/specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/CertificateCreate_MinimalCer.json
func ExampleCertificateClient_Create_createCertificateMinimalCer() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armbatch.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewCertificateClient().Create(ctx, "default-azurebatch-japaneast", "sampleacct", "sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e", armbatch.CertificateCreateOrUpdateParameters{
Properties: &armbatch.CertificateCreateOrUpdateProperties{
Format: to.Ptr(armbatch.CertificateFormatCer),
Data: to.Ptr("MIICrjCCAZagAwI..."),
},
}, &armbatch.CertificateClientCreateOptions{IfMatch: nil,
IfNoneMatch: 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.Certificate = armbatch.Certificate{
// Name: to.Ptr("sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e"),
// Type: to.Ptr("Microsoft.Batch/batchAccounts/certificates"),
// Etag: to.Ptr("W/\"0x8D4EDD5118668F7\""),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/samplecct/certificates/sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e"),
// Properties: &armbatch.CertificateProperties{
// Format: to.Ptr(armbatch.CertificateFormatCer),
// Thumbprint: to.Ptr("0a0e4f50d51beadeac1d35afc5116098e7902e6e"),
// ThumbprintAlgorithm: to.Ptr("sha1"),
// ProvisioningState: to.Ptr(armbatch.CertificateProvisioningStateSucceeded),
// ProvisioningStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-07-21T01:47:38.442Z"); return t}()),
// PublicData: to.Ptr("MIICrjCCAZagAwI..."),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { BatchManagementClient } = require("@azure/arm-batch");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Warning: This operation is deprecated and will be removed after February, 2024. Please use the [Azure KeyVault Extension](https://learn.microsoft.com/azure/batch/batch-certificate-migration-guide) instead.
*
* @summary Warning: This operation is deprecated and will be removed after February, 2024. Please use the [Azure KeyVault Extension](https://learn.microsoft.com/azure/batch/batch-certificate-migration-guide) instead.
* x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/CertificateCreate_MinimalCer.json
*/
async function createCertificateMinimalCer() {
const subscriptionId = process.env["BATCH_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["BATCH_RESOURCE_GROUP"] || "default-azurebatch-japaneast";
const accountName = "sampleacct";
const certificateName = "sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e";
const parameters = {
format: "Cer",
data: "MIICrjCCAZagAwI...",
};
const credential = new DefaultAzureCredential();
const client = new BatchManagementClient(credential, subscriptionId);
const result = await client.certificateOperations.create(
resourceGroupName,
accountName,
certificateName,
parameters,
);
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.Batch;
using Azure.ResourceManager.Batch.Models;
// Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/CertificateCreate_MinimalCer.json
// this example is just showing the usage of "Certificate_Create" 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 BatchAccountResource created on azure
// for more information of creating BatchAccountResource, please refer to the document of BatchAccountResource
string subscriptionId = "subid";
string resourceGroupName = "default-azurebatch-japaneast";
string accountName = "sampleacct";
ResourceIdentifier batchAccountResourceId = BatchAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName);
BatchAccountResource batchAccount = client.GetBatchAccountResource(batchAccountResourceId);
// get the collection of this BatchAccountCertificateResource
BatchAccountCertificateCollection collection = batchAccount.GetBatchAccountCertificates();
// invoke the operation
string certificateName = "sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e";
BatchAccountCertificateCreateOrUpdateContent content = new BatchAccountCertificateCreateOrUpdateContent()
{
Format = BatchAccountCertificateFormat.Cer,
Data = BinaryData.FromString("MIICrjCCAZagAwI..."),
};
ArmOperation<BatchAccountCertificateResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateName, content);
BatchAccountCertificateResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
BatchAccountCertificateData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
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
ETag: W/"0x8D4EDD5118668F7"
{
"id": "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/samplecct/certificates/sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e",
"name": "sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e",
"type": "Microsoft.Batch/batchAccounts/certificates",
"etag": "W/\"0x8D4EDD5118668F7\"",
"properties": {
"thumbprintAlgorithm": "sha1",
"thumbprint": "0a0e4f50d51beadeac1d35afc5116098e7902e6e",
"provisioningState": "Succeeded",
"provisioningStateTransitionTime": "2017-07-21T01:47:38.4420202Z",
"format": "Cer",
"publicData": "MIICrjCCAZagAwI..."
}
}
CreateCertificate - Minimal Pfx
Sample Request
PUT https://management.azure.com/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/certificates/sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e?api-version=2024-02-01
{
"properties": {
"data": "MIIJsgIBAzCCCW4GCSqGSIb3DQE...",
"password": "<ExamplePassword>"
}
}
/**
* Samples for Certificate Create.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/CertificateCreate_Minimal.json
*/
/**
* Sample code: CreateCertificate - Minimal Pfx.
*
* @param manager Entry point to BatchManager.
*/
public static void createCertificateMinimalPfx(com.azure.resourcemanager.batch.BatchManager manager) {
manager.certificates().define("sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e")
.withExistingBatchAccount("default-azurebatch-japaneast", "sampleacct").withPassword("<ExamplePassword>")
.create();
}
}
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.batch import BatchManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-batch
# USAGE
python certificate_create_minimal.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 = BatchManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.certificate.create(
resource_group_name="default-azurebatch-japaneast",
account_name="sampleacct",
certificate_name="sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e",
parameters={"properties": {"data": "MIIJsgIBAzCCCW4GCSqGSIb3DQE...", "password": "<ExamplePassword>"}},
)
print(response)
# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/CertificateCreate_Minimal.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 armbatch_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/batch/armbatch/v2"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/cf5ad1932d00c7d15497705ad6b71171d3d68b1e/specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/CertificateCreate_Minimal.json
func ExampleCertificateClient_Create_createCertificateMinimalPfx() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armbatch.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewCertificateClient().Create(ctx, "default-azurebatch-japaneast", "sampleacct", "sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e", armbatch.CertificateCreateOrUpdateParameters{
Properties: &armbatch.CertificateCreateOrUpdateProperties{
Data: to.Ptr("MIIJsgIBAzCCCW4GCSqGSIb3DQE..."),
Password: to.Ptr("<ExamplePassword>"),
},
}, &armbatch.CertificateClientCreateOptions{IfMatch: nil,
IfNoneMatch: 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.Certificate = armbatch.Certificate{
// Name: to.Ptr("sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e"),
// Type: to.Ptr("Microsoft.Batch/batchAccounts/certificates"),
// Etag: to.Ptr("W/\"0x8D4EDD5118668F7\""),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/samplecct/certificates/sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e"),
// Properties: &armbatch.CertificateProperties{
// Format: to.Ptr(armbatch.CertificateFormatPfx),
// Thumbprint: to.Ptr("0a0e4f50d51beadeac1d35afc5116098e7902e6e"),
// ThumbprintAlgorithm: to.Ptr("sha1"),
// ProvisioningState: to.Ptr(armbatch.CertificateProvisioningStateSucceeded),
// ProvisioningStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-07-21T01:47:38.442Z"); return t}()),
// PublicData: to.Ptr("MIICrjCCAZagAwI..."),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { BatchManagementClient } = require("@azure/arm-batch");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Warning: This operation is deprecated and will be removed after February, 2024. Please use the [Azure KeyVault Extension](https://learn.microsoft.com/azure/batch/batch-certificate-migration-guide) instead.
*
* @summary Warning: This operation is deprecated and will be removed after February, 2024. Please use the [Azure KeyVault Extension](https://learn.microsoft.com/azure/batch/batch-certificate-migration-guide) instead.
* x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/CertificateCreate_Minimal.json
*/
async function createCertificateMinimalPfx() {
const subscriptionId = process.env["BATCH_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["BATCH_RESOURCE_GROUP"] || "default-azurebatch-japaneast";
const accountName = "sampleacct";
const certificateName = "sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e";
const parameters = {
data: "MIIJsgIBAzCCCW4GCSqGSIb3DQE...",
password: "<ExamplePassword>",
};
const credential = new DefaultAzureCredential();
const client = new BatchManagementClient(credential, subscriptionId);
const result = await client.certificateOperations.create(
resourceGroupName,
accountName,
certificateName,
parameters,
);
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.Batch;
using Azure.ResourceManager.Batch.Models;
// Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/CertificateCreate_Minimal.json
// this example is just showing the usage of "Certificate_Create" 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 BatchAccountResource created on azure
// for more information of creating BatchAccountResource, please refer to the document of BatchAccountResource
string subscriptionId = "subid";
string resourceGroupName = "default-azurebatch-japaneast";
string accountName = "sampleacct";
ResourceIdentifier batchAccountResourceId = BatchAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName);
BatchAccountResource batchAccount = client.GetBatchAccountResource(batchAccountResourceId);
// get the collection of this BatchAccountCertificateResource
BatchAccountCertificateCollection collection = batchAccount.GetBatchAccountCertificates();
// invoke the operation
string certificateName = "sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e";
BatchAccountCertificateCreateOrUpdateContent content = new BatchAccountCertificateCreateOrUpdateContent()
{
Data = BinaryData.FromString("MIIJsgIBAzCCCW4GCSqGSIb3DQE..."),
Password = "<ExamplePassword>",
};
ArmOperation<BatchAccountCertificateResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateName, content);
BatchAccountCertificateResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
BatchAccountCertificateData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
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
ETag: W/"0x8D4EDD5118668F7"
{
"id": "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/samplecct/certificates/sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e",
"name": "sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e",
"type": "Microsoft.Batch/batchAccounts/certificates",
"etag": "W/\"0x8D4EDD5118668F7\"",
"properties": {
"thumbprintAlgorithm": "sha1",
"thumbprint": "0a0e4f50d51beadeac1d35afc5116098e7902e6e",
"provisioningState": "Succeeded",
"provisioningStateTransitionTime": "2017-07-21T01:47:38.4420202Z",
"format": "Pfx",
"publicData": "MIICrjCCAZagAwI..."
}
}
Definitions
Certificate
Contains information about a certificate.
Name |
Type |
Description |
etag
|
string
|
The ETag of the resource, used for concurrency statements.
|
id
|
string
|
The ID of the resource.
|
name
|
string
|
The name of the resource.
|
properties.deleteCertificateError
|
DeleteCertificateError
|
The error which occurred while deleting the certificate
This is only returned when the certificate provisioningState is 'Failed'.
|
properties.format
|
CertificateFormat
|
The format of the certificate - either Pfx or Cer. If omitted, the default is Pfx.
|
properties.previousProvisioningState
|
CertificateProvisioningState
|
The previous provisioned state of the resource
|
properties.previousProvisioningStateTransitionTime
|
string
|
The time at which the certificate entered its previous state.
|
properties.provisioningState
|
CertificateProvisioningState
|
The provisioned state of the resource
|
properties.provisioningStateTransitionTime
|
string
|
The time at which the certificate entered its current state.
|
properties.publicData
|
string
|
The public key of the certificate.
|
properties.thumbprint
|
string
|
The thumbprint of the certificate.
This must match the thumbprint from the name.
|
properties.thumbprintAlgorithm
|
string
|
The algorithm of the certificate thumbprint.
This must match the first portion of the certificate name. Currently required to be 'SHA1'.
|
type
|
string
|
The type of the resource.
|
CertificateCreateOrUpdateParameters
Contains information about a certificate.
Name |
Type |
Description |
etag
|
string
|
The ETag of the resource, used for concurrency statements.
|
id
|
string
|
The ID of the resource.
|
name
|
string
|
The name of the resource.
|
properties.data
|
string
|
The base64-encoded contents of the certificate.
The maximum size is 10KB.
|
properties.format
|
CertificateFormat
|
The format of the certificate - either Pfx or Cer. If omitted, the default is Pfx.
|
properties.password
|
string
|
The password to access the certificate's private key.
This must not be specified if the certificate format is Cer.
|
properties.thumbprint
|
string
|
The thumbprint of the certificate.
This must match the thumbprint from the name.
|
properties.thumbprintAlgorithm
|
string
|
The algorithm of the certificate thumbprint.
This must match the first portion of the certificate name. Currently required to be 'SHA1'.
|
type
|
string
|
The type of the resource.
|
The format of the certificate - either Pfx or Cer. If omitted, the default is Pfx.
Name |
Type |
Description |
Cer
|
string
|
The certificate is a base64-encoded X.509 certificate.
|
Pfx
|
string
|
The certificate is a PFX (PKCS#12) formatted certificate or certificate chain.
|
CertificateProvisioningState
The provisioned state of the resource
Name |
Type |
Description |
Deleting
|
string
|
The user has requested that the certificate be deleted, but the delete operation has not yet completed. You may not reference the certificate when creating or updating pools.
|
Failed
|
string
|
The user requested that the certificate be deleted, but there are pools that still have references to the certificate, or it is still installed on one or more compute nodes. (The latter can occur if the certificate has been removed from the pool, but the node has not yet restarted. Nodes refresh their certificates only when they restart.) You may use the cancel certificate delete operation to cancel the delete, or the delete certificate operation to retry the delete.
|
Succeeded
|
string
|
The certificate is available for use in pools.
|
CloudError
An error response from the Batch service.
Name |
Type |
Description |
error
|
CloudErrorBody
|
The body of the error response.
|
CloudErrorBody
An error response from the Batch service.
Name |
Type |
Description |
code
|
string
|
An identifier for the error. Codes are invariant and are intended to be consumed programmatically.
|
details
|
CloudErrorBody[]
|
A list of additional details about the error.
|
message
|
string
|
A message describing the error, intended to be suitable for display in a user interface.
|
target
|
string
|
The target of the particular error. For example, the name of the property in error.
|
DeleteCertificateError
An error response from the Batch service.
Name |
Type |
Description |
code
|
string
|
An identifier for the error. Codes are invariant and are intended to be consumed programmatically.
|
details
|
DeleteCertificateError[]
|
A list of additional details about the error.
|
message
|
string
|
A message describing the error, intended to be suitable for display in a user interface.
|
target
|
string
|
The target of the particular error. For example, the name of the property in error.
|