DeviceManagementClient.CreateOrUpdateDeployment メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
デプロイを作成または更新します。
public virtual Azure.Response CreateOrUpdateDeployment (string groupId, string deploymentId, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member CreateOrUpdateDeployment : string * string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
override this.CreateOrUpdateDeployment : string * string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
Public Overridable Function CreateOrUpdateDeployment (groupId As String, deploymentId As String, content As RequestContent, Optional context As RequestContext = Nothing) As Response
パラメーター
- groupId
- String
グループ識別子。
- deploymentId
- String
デプロイ識別子。
- content
- RequestContent
要求の本文として送信するコンテンツ。 要求本文スキーマの詳細については、以下の「解説」セクションを参照してください。
- context
- RequestContext
要求コンテキスト。これは、クライアント パイプラインの既定の動作を呼び出しごとにオーバーライドできます。
戻り値
サービスから返された応答。 応答本文スキーマの詳細については、以下の「解説」セクションを参照してください。
例外
groupId
、deploymentId
、または content
が null です。
groupId
または deploymentId
が空の文字列であり、空でないと想定されていました。
サービスから成功以外の状態コードが返されました。
例
このサンプルでは、必要なパラメーターと要求コンテンツを使用して CreateOrUpdateDeployment を呼び出す方法と、結果を解析する方法を示します。
var credential = new DefaultAzureCredential();
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new DeviceManagementClient(endpoint, "<instanceId>", credential);
var data = new {
deploymentId = "<deploymentId>",
startDateTime = "2022-05-10T18:57:31.2311892Z",
update = new {
updateId = new {
provider = "<provider>",
name = "<name>",
version = "<version>",
},
},
groupId = "<groupId>",
};
Response response = client.CreateOrUpdateDeployment("<groupId>", "<deploymentId>", RequestContent.Create(data));
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("deploymentId").ToString());
Console.WriteLine(result.GetProperty("startDateTime").ToString());
Console.WriteLine(result.GetProperty("update").GetProperty("updateId").GetProperty("provider").ToString());
Console.WriteLine(result.GetProperty("update").GetProperty("updateId").GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("update").GetProperty("updateId").GetProperty("version").ToString());
Console.WriteLine(result.GetProperty("groupId").ToString());
このサンプルでは、すべてのパラメーターと要求コンテンツを使用して CreateOrUpdateDeployment を呼び出す方法と、結果を解析する方法を示します。
var credential = new DefaultAzureCredential();
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new DeviceManagementClient(endpoint, "<instanceId>", credential);
var data = new {
deploymentId = "<deploymentId>",
startDateTime = "2022-05-10T18:57:31.2311892Z",
update = new {
updateId = new {
provider = "<provider>",
name = "<name>",
version = "<version>",
},
},
groupId = "<groupId>",
deviceClassSubgroups = new[] {
"<String>"
},
isCanceled = true,
isRetried = true,
rollbackPolicy = new {
update = new {
updateId = new {
provider = "<provider>",
name = "<name>",
version = "<version>",
},
},
failure = new {
devicesFailedPercentage = 1234,
devicesFailedCount = 1234,
},
},
isCloudInitiatedRollback = true,
};
Response response = client.CreateOrUpdateDeployment("<groupId>", "<deploymentId>", RequestContent.Create(data));
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("deploymentId").ToString());
Console.WriteLine(result.GetProperty("startDateTime").ToString());
Console.WriteLine(result.GetProperty("update").GetProperty("updateId").GetProperty("provider").ToString());
Console.WriteLine(result.GetProperty("update").GetProperty("updateId").GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("update").GetProperty("updateId").GetProperty("version").ToString());
Console.WriteLine(result.GetProperty("update").GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("update").GetProperty("friendlyName").ToString());
Console.WriteLine(result.GetProperty("groupId").ToString());
Console.WriteLine(result.GetProperty("deviceClassSubgroups")[0].ToString());
Console.WriteLine(result.GetProperty("isCanceled").ToString());
Console.WriteLine(result.GetProperty("isRetried").ToString());
Console.WriteLine(result.GetProperty("rollbackPolicy").GetProperty("update").GetProperty("updateId").GetProperty("provider").ToString());
Console.WriteLine(result.GetProperty("rollbackPolicy").GetProperty("update").GetProperty("updateId").GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("rollbackPolicy").GetProperty("update").GetProperty("updateId").GetProperty("version").ToString());
Console.WriteLine(result.GetProperty("rollbackPolicy").GetProperty("update").GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("rollbackPolicy").GetProperty("update").GetProperty("friendlyName").ToString());
Console.WriteLine(result.GetProperty("rollbackPolicy").GetProperty("failure").GetProperty("devicesFailedPercentage").ToString());
Console.WriteLine(result.GetProperty("rollbackPolicy").GetProperty("failure").GetProperty("devicesFailedCount").ToString());
Console.WriteLine(result.GetProperty("isCloudInitiatedRollback").ToString());
注釈
要求と応答のペイロードの JSON スキーマを次に示します。
要求本文:
の Deployment
スキーマ:
{
deploymentId: string, # Required. The caller-provided deployment identifier. This cannot be longer than 73 characters, must be all lower-case, and cannot contain '&', '^', '[', ']', '{', '}', '|', '<', '>', forward slash, backslash, or double quote. The Updates view in the Azure Portal IoT Hub resource generates a GUID for deploymentId when you create a deployment.
startDateTime: string (ISO 8601 Format), # Required. The deployment start datetime.
update: {
updateId: {
provider: string, # Required. Update provider.
name: string, # Required. Update name.
version: string, # Required. Update version.
}, # Required. Update identifier.
description: string, # Optional. Update description.
friendlyName: string, # Optional. Friendly update name.
}, # Required. Update information for the update in the deployment.
groupId: string, # Required. The group identity for the devices the deployment is intended to update.
deviceClassSubgroups: [string], # Optional. The device class subgroups the deployment is compatible with and subgroup deployments have been created for. This is not provided by the caller during CreateOrUpdateDeployment but is automatically determined by Device Update
isCanceled: boolean, # Optional. Boolean flag indicating whether the deployment was canceled.
isRetried: boolean, # Optional. Boolean flag indicating whether the deployment has been retried.
rollbackPolicy: {
update: UpdateInfo, # Required. Update to rollback to.
failure: {
devicesFailedPercentage: number, # Required. Percentage of devices that failed.
devicesFailedCount: number, # Required. Number of devices that failed.
}, # Required. Failure conditions to initiate rollback policy.
}, # Optional. The rollback policy for the deployment.
isCloudInitiatedRollback: boolean, # Optional. Boolean flag indicating whether the deployment is a rollback deployment.
}
応答本文:
の Deployment
スキーマ:
{
deploymentId: string, # Required. The caller-provided deployment identifier. This cannot be longer than 73 characters, must be all lower-case, and cannot contain '&', '^', '[', ']', '{', '}', '|', '<', '>', forward slash, backslash, or double quote. The Updates view in the Azure Portal IoT Hub resource generates a GUID for deploymentId when you create a deployment.
startDateTime: string (ISO 8601 Format), # Required. The deployment start datetime.
update: {
updateId: {
provider: string, # Required. Update provider.
name: string, # Required. Update name.
version: string, # Required. Update version.
}, # Required. Update identifier.
description: string, # Optional. Update description.
friendlyName: string, # Optional. Friendly update name.
}, # Required. Update information for the update in the deployment.
groupId: string, # Required. The group identity for the devices the deployment is intended to update.
deviceClassSubgroups: [string], # Optional. The device class subgroups the deployment is compatible with and subgroup deployments have been created for. This is not provided by the caller during CreateOrUpdateDeployment but is automatically determined by Device Update
isCanceled: boolean, # Optional. Boolean flag indicating whether the deployment was canceled.
isRetried: boolean, # Optional. Boolean flag indicating whether the deployment has been retried.
rollbackPolicy: {
update: UpdateInfo, # Required. Update to rollback to.
failure: {
devicesFailedPercentage: number, # Required. Percentage of devices that failed.
devicesFailedCount: number, # Required. Number of devices that failed.
}, # Required. Failure conditions to initiate rollback policy.
}, # Optional. The rollback policy for the deployment.
isCloudInitiatedRollback: boolean, # Optional. Boolean flag indicating whether the deployment is a rollback deployment.
}
適用対象
Azure SDK for .NET