你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
DeviceUpdateClient.GetUpdateAsync 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取特定的更新版本。
public virtual System.Threading.Tasks.Task<Azure.Response> GetUpdateAsync (string provider, string name, string version, Azure.ETag? ifNoneMatch = default, Azure.RequestContext context = default);
abstract member GetUpdateAsync : string * string * string * Nullable<Azure.ETag> * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.GetUpdateAsync : string * string * string * Nullable<Azure.ETag> * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function GetUpdateAsync (provider As String, name As String, version As String, Optional ifNoneMatch As Nullable(Of ETag) = Nothing, Optional context As RequestContext = Nothing) As Task(Of Response)
参数
- provider
- String
更新提供程序。
- name
- String
更新名称。
- version
- String
更新版本。
- context
- RequestContext
请求上下文,它可以基于每个调用替代客户端管道的默认行为。
返回
从服务返回的响应。 响应正文架构的详细信息位于下面的“备注”部分。
例外
provider
、name
或 version
为 null。
provider
, name
或 version
是空字符串,预期为非空。
服务返回了不成功状态代码。
示例
此示例演示如何使用所需的参数调用 GetUpdateAsync 并分析结果。
var credential = new DefaultAzureCredential();
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new DeviceUpdateClient(endpoint, "<instanceId>", credential);
Response response = await client.GetUpdateAsync("<provider>", "<name>", "<version>");
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("updateId").GetProperty("provider").ToString());
Console.WriteLine(result.GetProperty("updateId").GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("updateId").GetProperty("version").ToString());
Console.WriteLine(result.GetProperty("compatibility")[0].GetProperty("<test>").ToString());
Console.WriteLine(result.GetProperty("manifestVersion").ToString());
Console.WriteLine(result.GetProperty("importedDateTime").ToString());
Console.WriteLine(result.GetProperty("createdDateTime").ToString());
此示例演示如何使用所有参数调用 GetUpdateAsync,以及如何分析结果。
var credential = new DefaultAzureCredential();
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new DeviceUpdateClient(endpoint, "<instanceId>", credential);
Response response = await client.GetUpdateAsync("<provider>", "<name>", "<version>", null);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("updateId").GetProperty("provider").ToString());
Console.WriteLine(result.GetProperty("updateId").GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("updateId").GetProperty("version").ToString());
Console.WriteLine(result.GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("friendlyName").ToString());
Console.WriteLine(result.GetProperty("isDeployable").ToString());
Console.WriteLine(result.GetProperty("updateType").ToString());
Console.WriteLine(result.GetProperty("installedCriteria").ToString());
Console.WriteLine(result.GetProperty("compatibility")[0].GetProperty("<test>").ToString());
Console.WriteLine(result.GetProperty("instructions").GetProperty("steps")[0].GetProperty("type").ToString());
Console.WriteLine(result.GetProperty("instructions").GetProperty("steps")[0].GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("instructions").GetProperty("steps")[0].GetProperty("handler").ToString());
Console.WriteLine(result.GetProperty("instructions").GetProperty("steps")[0].GetProperty("handlerProperties").ToString());
Console.WriteLine(result.GetProperty("instructions").GetProperty("steps")[0].GetProperty("files")[0].ToString());
Console.WriteLine(result.GetProperty("instructions").GetProperty("steps")[0].GetProperty("updateId").GetProperty("provider").ToString());
Console.WriteLine(result.GetProperty("instructions").GetProperty("steps")[0].GetProperty("updateId").GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("instructions").GetProperty("steps")[0].GetProperty("updateId").GetProperty("version").ToString());
Console.WriteLine(result.GetProperty("referencedBy")[0].GetProperty("provider").ToString());
Console.WriteLine(result.GetProperty("referencedBy")[0].GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("referencedBy")[0].GetProperty("version").ToString());
Console.WriteLine(result.GetProperty("scanResult").ToString());
Console.WriteLine(result.GetProperty("manifestVersion").ToString());
Console.WriteLine(result.GetProperty("importedDateTime").ToString());
Console.WriteLine(result.GetProperty("createdDateTime").ToString());
Console.WriteLine(result.GetProperty("etag").ToString());
注解
下面是响应有效负载的 JSON 架构。
响应正文:
的 Update
架构:
{
updateId: {
provider: string, # Required. Update provider.
name: string, # Required. Update name.
version: string, # Required. Update version.
}, # Required. Update identity.
description: string, # Optional. Update description specified by creator.
friendlyName: string, # Optional. Friendly update name specified by importer.
isDeployable: boolean, # Optional. Whether the update can be deployed to a device on its own.
updateType: string, # Optional. Update type. Deprecated in latest import manifest schema.
installedCriteria: string, # Optional. String interpreted by Device Update client to determine if the update is installed on the device. Deprecated in latest import manifest schema.
compatibility: [Dictionary<string, string>], # Required. List of update compatibility information.
instructions: {
steps: [
{
type: "Inline" | "Reference", # Optional. Step type.
description: string, # Optional. Step description.
handler: string, # Optional. Identity of handler that will execute this step. Required if step type is inline.
handlerProperties: AnyObject, # Optional. Parameters to be passed to handler during execution.
files: [string], # Optional. Collection of file names to be passed to handler during execution. Required if step type is inline.
updateId: UpdateId, # Optional. Referenced child update identity. Required if step type is reference.
}
], # Required. Collection of installation steps.
}, # Optional. Update install instructions.
referencedBy: [UpdateId], # Optional. List of update identities that reference this update.
scanResult: string, # Optional. Update aggregate scan result (calculated from payload file scan results).
manifestVersion: string, # Required. Schema version of manifest used to import the update.
importedDateTime: string (ISO 8601 Format), # Required. Date and time in UTC when the update was imported.
createdDateTime: string (ISO 8601 Format), # Required. Date and time in UTC when the update was created.
etag: string, # Optional. Update ETag.
}