azure - [Azure 部署] : Can we filter Azure Resource Group Deployments by name using c#?

标签 azure azure-resource-manager azure-deployment

我尝试使用名称以“Deploy”开头的过滤器来获取 Azure 资源组部署,但找不到有关 $filter 的任何文档。

我尝试做如下的事情:

try
{
    var credentials = new ClientSecretCredential(tenantId, clientId, clientSecret);
    var resourceClient = new ResourcesManagementClient(subscriptionId, credentials);
    var deployments = resourceClient.Deployments;
    AsyncPageable<DeploymentExtended> rgDeployments = deployments.ListByResourceGroupAsync("myRG", "name eq 'Deploy-20210412184314'");
    await foreach (DeploymentExtended deploymentProperties in rgDeployments)
    {
        Trace.WriteLine(deploymentProperties.Name);
    }
}
catch(Exception e)
{
    Trace.WriteLine(e.Message);
}

但它给出错误说 -

{"error":{"code":"InvalidProvisioningStateFilter","message":"Invalid $filter 'name eq 'Deploy-20210412184314'' specified in the query string."}}

那么我们可以只使用像 provisioningState eq '{state}' 这样的过滤器而不是名称吗?

我正在使用Azure Resources Management client library for .NET .

请引用此documentation .

最佳答案

恐怕您无法使用 name eq 'Deploy-20210412184314' 的过滤器,在这种情况下,如果您已经知道部署的名称并希望在资源组中获取它范围,无需使用ListByResourceGroupAsync,只需使用此方法 DeploymentsOperations.GetAsync(String, String, CancellationToken) ,传入resourceGroupNamedeploymentName,即可轻松获取。

关于azure - [Azure 部署] : Can we filter Azure Resource Group Deployments by name using c#?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67069782/

相关文章:

c# - 从 Azure 使用 C# 获取 XML 文件作为响应

azure - 一台服务器可以拥有的 IIS 应用程序池数量是否有限制?

azure - 我可以在一个站点拥有多个地址吗?

json - 如何使用 Azure 资源管理器在 Azure Web 应用程序中设置应用程序日志

azure - 如何使现有 ARM 模板上的资源 API 版本保持最新?

azure - 基础设施版本控制 持续部署

node.js - 如何修复 Linux 中 NodeJs Azure Functions 上的 "Error:/home/site/wwwroot/node_modules/canvas/build/Release/canvas.node: invalid ELF header"?

Azure DevOps 部署显示 InvalidRequestContent : Request content contains one or more instances of unsupported reference property names

azure - 我们如何将整个 web.config 从 staging slot 转换为 azure 中的生产 slot?

azure - 使用 Azure 队列存储为每个队列配置 QueueTrigger