首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何仅使用Microsoft.WindowsAzure.Management库向azure云服务添加诊断?

如何仅使用Microsoft.WindowsAzure.Management库向azure云服务添加诊断?
EN

Stack Overflow用户
提问于 2016-12-02 22:05:41
回答 1查看 50关注 0票数 2

我根本不想让PowerShell牵扯进来。我可以很好地创建云服务,并且我的诊断配置文件作为worker角色的根目录的一部分。你怎么打开这个扩展呢?

EN

回答 1

Stack Overflow用户

发布于 2016-12-02 23:31:02

我自己发现的。

代码语言:javascript
复制
        var etcs = cloudClient.HostedServices.ListAvailableExtensions();

        var et = etcs.FirstOrDefault(p => p.Type == "PaaSDiagnostics");





        cloudClient.HostedServices.AddExtension("agent1", new Microsoft.WindowsAzure.Management.Compute.Models.HostedServiceAddExtensionParameters()
        {
            Type = et.Type,
            ProviderNamespace = et.ProviderNameSpace,
            Id = "testext",
            Version = et.Version,
            PublicConfiguration = File.ReadAllText(@"PubConfig.xml"),
            PrivateConfiguration = "<?xml version=\"1.0\" encoding=\"utf-8\"?><PrivateConfig xmlns=\"http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration\"><StorageAccount name=\"store\" key=\"" + ks.SecondaryKey + "\"></StorageAccount></PrivateConfig>"


        });



        var id = cloudClient.Deployments.Create("agent1", Microsoft.WindowsAzure.Management.Compute.Models.DeploymentSlot.Production, new Microsoft.WindowsAzure.Management.Compute.Models.DeploymentCreateParameters()
        {
            Name = "test",
            Configuration = File.ReadAllText(@"ServiceConfiguration.Cloud.cscfg"),
            PackageUri = blob.Uri,
            Label = "Test",
            StartDeployment = true,
            ExtensionConfiguration = new Microsoft.WindowsAzure.Management.Compute.Models.ExtensionConfiguration()
            {
                AllRoles = new[] { new Microsoft.WindowsAzure.Management.Compute.Models.ExtensionConfiguration.Extension ()
                  {
                       Id = "testext",
                        State = "Enable"
                  }}
            }

        });
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40934057

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档