得到ServiceDefinition定义Azure的所有站点 [英] Get all Sites Defined in ServiceDefinition for Azure

查看:99
本文介绍了得到ServiceDefinition定义Azure的所有站点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以定义 ServiceDefinition.csdef中

我想知道如何获得programely名单。我打得四处 RoleEnvironment 类,但不能得到一个线索。请帮助

I want to know how to get the list programely. I played around RoleEnvironment class but cannot get a clue. Please help

推荐答案

对于大多数兼容性(而不是依靠无证实现细节,可以改变),你应该使用,你会在$ P $使用相同的方法pmises。使用 Microsoft.Web.Administration 组装和 ServerManager的类。它包含了网站收集你所需要的所有细节。

For the most compatibility (and not to rely on undocumented implementation details that can change), you should just use the same method that you would use on premises. Use Microsoft.Web.Administration assembly and the ServerManager class. It contains a Sites collection with all the details you need.

using (ServerManager serverManager = new ServerManager())
{ 
    var sites = serverManager.Sites; 
    foreach (Site site in sites) 
        Console.WriteLine(site.Name); // This will return the WebSite name
}

这篇关于得到ServiceDefinition定义Azure的所有站点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆