読者です 読者をやめる 読者になる 読者になる

Azureの小ネタ (改)

~Azureネタを中心に、色々とその他の技術的なことなどを~

Azure Diagnosticsを構成するためのスキーマファイルを取得する

例によって個人的備忘録で、Azure Diagnosticsを構成するためのスキーマファイルを取得する方法です。

以下からの一部抜粋ですが、

How to use diagnostics (.NET) - Azure feature guide

Get-AzureServiceAvailableExtensionを使うと、Diag以外にも各種エクステンションのXSDファイルが取得できます。

(Get-AzureServiceAvailableExtension -ExtensionName 'PaaSDiagnostics' -ProviderNamespace 'Microsoft.Azure.Diagnostics').PublicConfigurationSchema | Out-File -Encoding utf8 -FilePath 'WadConfig.xsd' 

名前は、Paasとなっていますが、Diagnosticsの場合、仮想マシンもこのスキーマでいけます。

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="DiagnosticsConfigSchema"
    targetNamespace="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration"
    elementFormDefault="qualified"
    xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration"
    xmlns:wad="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration"
    xmlns:mstns="http://tempuri.org/XMLSchema.xsd"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:simpleType name="PositiveDuration">
    <xs:restriction base="xs:duration">
      <xs:minInclusive value="PT0S" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="LogLevel">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Undefined" />
      <xs:enumeration value="Verbose" />
      <xs:enumeration value="Information" />
      <xs:enumeration value="Warning" />
      <xs:enumeration value="Error" />
      <xs:enumeration value="Critical" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="ContainerName">
    <xs:restriction base="xs:string">
       <!-- 
       container can be between 3 to 63 chars. a char can be a lower case letter or digit or a '-' 
       There cannot be 2 consecutive '-' and it cannot start or end with '-'
       -->
        <xs:minLength value="3"/>
        <xs:maxLength value="63"/>
        <xs:pattern  value="[a-z0-9]+(\-([a-z0-9])+)*[a-z0-9]*" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="locale">
    <xs:restriction base="xs:string">
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="displayName">
    <xs:restriction base="xs:string">
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="AbsolutePathWithEnvironmentExpansion">
    <xs:restriction base="xs:string">
      <xs:pattern value="([a-zA-Z]:\\)?([^&lt;&gt;:&quot;/|?*]+)*(\\)?" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="RelativePathWithEnvironmentExpansion">
    <xs:restriction base="xs:string">
      <xs:pattern value="([^&lt;&gt;:&quot;/\\|?*]+)(\\([^&lt;&gt;:&quot;/\\|?*]+))*(\\)?" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="PerformanceCounterPath">
    <xs:restriction base="xs:string">
      <xs:pattern value="\\.*" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="EventNameType">
    <xs:restriction base="xs:string">
      <xs:pattern value="[a-zA-Z][a-zA-Z0-9]{0,59}" />
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="CrashDumpType" >
    <xs:restriction base="xs:string">
      <xs:enumeration value="Mini"/>
      <xs:enumeration value="Full"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="NamedElementNameString">
    <xs:restriction base="xs:string">
      <xs:pattern value="^[a-zA-Z_][^\\\/\:\*\?\&quot;\&lt;\&gt;\|]*(?&lt;![\.\s])$" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="format">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Manifest" />
      <xs:enumeration value="EventSource" />
    </xs:restriction>
  </xs:simpleType>

    <xs:simpleType name="directoryQuotaPercentage">
      <xs:restriction base="xs:integer">
        <xs:minInclusive value="0"/>
        <xs:maxInclusive value="100"/>
      </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="guidType">
      <xs:annotation>
          <xs:documentation>
            A GUID. Brackets (and only brackets) before and/or after are ignored. e.g. {12345678-1234-1234-1234-123456789abc}, {12345678-1234-1234-1234-123456789abc, 12345678-1234-1234-1234-123456789abc} and 12345678-1234-1234-1234-123456789abc are valid.
          </xs:documentation>
      </xs:annotation>
      <xs:restriction base="xs:string">
        <xs:pattern value="^(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}$"/>
      </xs:restriction>
    </xs:simpleType>

  <xs:attributeGroup name="BasicConfiguration">
    <xs:attribute name="scheduledTransferPeriod" type="PositiveDuration" use="optional" default="PT0S">
      <xs:annotation>
        <xs:documentation>
          The interval between scheduled transfers for this data, rounded up to the nearest minute.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:attributeGroup>

  <xs:attributeGroup name="ETWConfiguration">
    <xs:attribute name="scheduledTransferPeriod" type="PositiveDuration" use="optional" default="PT0S">
      <xs:annotation>
        <xs:documentation>
          The interval between scheduled transfers for this data, rounded up to the nearest minute.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="scheduledTransferLogLevelFilter" type="LogLevel" use="optional" default="Undefined">
      <xs:annotation>
        <xs:documentation>
          The minimum log severity to transfer.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="provider" type="xs:string" use="required">
      <xs:annotation>
        <xs:documentation>
          The provider guid or class name for event source
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="scheduledTransferKeywordFilter" type="xs:unsignedLong" use="optional" default="0" >
      <xs:annotation>
        <xs:documentation>
          The keyword to filter by
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:attributeGroup>


  <xs:attributeGroup name="LogLevel">
    <xs:attribute name="scheduledTransferLogLevelFilter" type="LogLevel" use="optional" default="Undefined">
      <xs:annotation>
        <xs:documentation>
          The minimum log severity to transfer.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:attributeGroup>

  <xs:attributeGroup name="DirectoryAttributes">
    <xs:attribute name="containerName" type="wad:ContainerName" use="required">
      <xs:annotation>
        <xs:documentation>
          The name of the container where the content of the directory is to be transferred.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:attributeGroup>

  <xs:attributeGroup name="CrashDumpConfiguration">
    <xs:attribute name="directoryQuotaPercentage" type="directoryQuotaPercentage" use="optional" default="10">
      <xs:annotation>
        <xs:documentation>
          The percentage of directory quota used by crashdumps
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="dumpType" type="CrashDumpType" use="optional" default="Mini">
      <xs:annotation>
        <xs:documentation>
          The type of crashdump
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="containerName" type="wad:ContainerName" use="optional" default="wad-crashdumps">
      <xs:annotation>
        <xs:documentation>
          The blob container to store the crashdumps
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:attributeGroup>

  <xs:complexType name="LogsBase">
    <xs:attributeGroup ref="BasicConfiguration" />
  </xs:complexType>

  <xs:complexType name="EtwEventsBase">
    <xs:attributeGroup ref="ETWConfiguration" />
  </xs:complexType>

  <xs:complexType name ="CrashDumpsBase">
    <xs:attributeGroup ref="CrashDumpConfiguration"/>
  </xs:complexType>

  <xs:complexType name="EtwManifestProviderConfiguration">
    <xs:complexContent>
      <xs:extension base="EtwEventsBase">
        <xs:sequence>
            <xs:element maxOccurs="unbounded" name="Event" minOccurs="0">
              <xs:complexType>
                <xs:attribute name="id" type="xs:int" use="required">
                  <xs:annotation>
                    <xs:documentation>
                      The id of the ETW event that is to be collected
                    </xs:documentation>
                  </xs:annotation>
                </xs:attribute>
                <xs:attribute name="eventDestination" type="EventNameType" use="optional">
                  <xs:annotation>
                    <xs:documentation>
                      The name of the table in which the event data will be stored. If this attribute is not defined the table's name is 'Event'+'MD5 of the provider'+EventId#.
                    </xs:documentation>
                  </xs:annotation>
                </xs:attribute>
              </xs:complexType>
            </xs:element>
            <xs:element name="DefaultEvents" minOccurs="0" maxOccurs="1">
              <xs:complexType>
                <xs:attribute name="eventDestination" type="EventNameType" use="optional">
                  <xs:annotation>
                    <xs:documentation>
                      The name of the table in which the event data will be stored. If this attribute is not defined the table's name is 'Default'+'MD5 of the provider'+EventId#.
                    </xs:documentation>
                  </xs:annotation>
                </xs:attribute>
              </xs:complexType>
            </xs:element>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="EtwEventSourceProviderConfiguration">
    <xs:complexContent>
      <xs:extension base="EtwEventsBase">
        <xs:sequence>
            <xs:element maxOccurs="unbounded" name="Event" minOccurs="0">
              <xs:complexType>
                <xs:attribute name="id" type="xs:int" use="required">
                  <xs:annotation>
                    <xs:documentation>
                      The id of the ETW event that is to be collected
                    </xs:documentation>
                  </xs:annotation>
                </xs:attribute>
                <xs:attribute name="eventDestination" type="EventNameType" use="optional">
                  <xs:annotation>
                    <xs:documentation>
                      The name of the table in which the event data will be stored. If this attribute is not defined the table's name is 'Event'+'MD5 of the provider'+EventId#.
                    </xs:documentation>
                  </xs:annotation>
                </xs:attribute>
              </xs:complexType>
            </xs:element>
            <xs:element name="DefaultEvents" minOccurs="0" maxOccurs="1">
              <xs:complexType>
                <xs:attribute name="eventDestination" type="EventNameType" use="optional">
                  <xs:annotation>
                    <xs:documentation>
                      The name of the table in which the event data will be stored. If this attribute is not defined the table's name is 'Default'+'MD5 of the provider'+EventId#.
                    </xs:documentation>
                  </xs:annotation>
                </xs:attribute>
              </xs:complexType>
            </xs:element>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="EtwProviders">
      <xs:sequence maxOccurs="unbounded">
        <xs:element  name="EtwEventSourceProviderConfiguration" type="EtwEventSourceProviderConfiguration" minOccurs="0" >
            <xs:annotation>
              <xs:documentation>
                ETW collection by event source
              </xs:documentation>
            </xs:annotation>
          </xs:element>
        <xs:element  name="EtwManifestProviderConfiguration" type="EtwManifestProviderConfiguration" minOccurs="0">
          <xs:annotation>
            <xs:documentation>
              ETW collection by manifest
            </xs:documentation>
          </xs:annotation>
        </xs:element>
        </xs:sequence>
  </xs:complexType>

  <xs:complexType name="CrashDumpConfiguration">
    <xs:attribute name="processName" type="xs:string" use="required">
      <xs:annotation>
        <xs:documentation>
          The name of the process to to monitor for crashes.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="CrashDumps">
    <xs:complexContent>
      <xs:extension base="CrashDumpsBase">
        <xs:sequence maxOccurs="unbounded">
          <xs:element name="CrashDumpConfiguration" type="CrashDumpConfiguration">
            <xs:annotation>
              <xs:documentation>
                The crashdump to collect
              </xs:documentation>
            </xs:annotation>
          </xs:element>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="DiagnosticInfrastructureLogs">
    <xs:complexContent>
      <xs:extension base="LogsBase">
        <xs:attributeGroup ref="LogLevel" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>


  <xs:complexType name="DirectoryBase" />

  <xs:complexType name="DirectoryAbsolute">
    <xs:complexContent>
      <xs:extension base="DirectoryBase">
        <xs:attribute name="path" type="AbsolutePathWithEnvironmentExpansion" use="required">
          <xs:annotation>
            <xs:documentation>
              The absolute path to the directory to monitor.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="expandEnvironment" type="xs:boolean" use="required">
          <xs:annotation>
            <xs:documentation>
              If true, then environment variables in the path will be expanded.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="DirectoryLocalResource">
    <xs:complexContent>
      <xs:extension base="DirectoryBase">
        <xs:attribute name="relativePath" type="RelativePathWithEnvironmentExpansion" use="required">
          <xs:annotation>
            <xs:documentation>
              The path relative to the local resource to monitor.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="name" type="NamedElementNameString" use="required">
          <xs:annotation>
            <xs:documentation>
              The local resource that contains the directory to monitor.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="DirectoryConfiguration">
    <xs:choice>
      <xs:element name="Absolute" type="DirectoryAbsolute">
        <xs:annotation>
          <xs:documentation>
            The absolute path to the directory to monitor.
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="LocalResource" type="DirectoryLocalResource">
        <xs:annotation>
          <xs:documentation>
            The path relative to a local resource to monitor.
          </xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:choice>
    <xs:attributeGroup ref="DirectoryAttributes" />
  </xs:complexType>

  <xs:complexType name="SpecialLogDirectory">
    <xs:attributeGroup ref="DirectoryAttributes" />
  </xs:complexType>

  <xs:complexType name="DataSources">
    <xs:sequence>
      <xs:element name="DirectoryConfiguration" type="DirectoryConfiguration" maxOccurs="unbounded">
        <xs:annotation>
          <xs:documentation>
            The directory of log files to monitor.
          </xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="Directories">
    <xs:complexContent>
      <xs:extension base="LogsBase">
        <xs:all>
          <xs:element name="IISLogs" type="SpecialLogDirectory" minOccurs="0">
            <xs:annotation>
              <xs:documentation>
                The IIS log directory.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="FailedRequestLogs" type="SpecialLogDirectory" minOccurs="0">
            <xs:annotation>
              <xs:documentation>
                The failed request log directory.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="DataSources" type="DataSources" minOccurs="0">
            <xs:annotation>
              <xs:documentation>
                Additional log directories.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
        </xs:all>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="annotation">
    <xs:attribute name="displayName" type="displayName" use="required">
      <xs:annotation>
        <xs:documentation>
          The display name for the performance counter.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="locale" type="locale" use="optional" default="en-US">
      <xs:annotation>
      <xs:documentation>
        The locale for the performance counter diplay name.
      </xs:documentation>
        </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="PerformanceCounterConfiguration">
    <xs:sequence minOccurs="0">
      <xs:element maxOccurs="unbounded" name="annotation" type="annotation">
        <xs:annotation>
          <xs:documentation>
            The display name and locale for the performance counter
          </xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="counterSpecifier" type="PerformanceCounterPath" use="required">
      <xs:annotation>
        <xs:documentation>
          The path to the performance counter to collect.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="sampleRate" type="PositiveDuration" use="required">
      <xs:annotation>
        <xs:documentation>
          The rate at which the performance counter should be sampled.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="unit" type="xs:string" use="optional">
      <xs:annotation>
        <xs:documentation>
          The unit for the performance counter for display purposes.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>


  <xs:complexType name="PerformanceCounters">
    <xs:complexContent>
      <xs:extension base="LogsBase">
        <xs:sequence maxOccurs="unbounded">
          <xs:element name="PerformanceCounterConfiguration" type="PerformanceCounterConfiguration">
            <xs:annotation>
              <xs:documentation>
                The performance counter to collect.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>



  <xs:complexType name="DataSource">
    <xs:attribute name="name" type="xs:string" use="required">
      <xs:annotation>
        <xs:documentation>
          An XPath expression specifying the logs to collect.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="WindowsEventLog">
    <xs:complexContent>
      <xs:extension base="LogsBase">
        <xs:sequence maxOccurs="unbounded">
          <xs:element name="DataSource" type="DataSource">
            <xs:annotation>
              <xs:documentation>
                The event log to monitor.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name ="MetricAggregation">
    <xs:attribute name="scheduledTransferPeriod" type="PositiveDuration" use="required" />  
  </xs:complexType>
    
  <xs:complexType name="Metrics">
    <xs:sequence>
        <xs:element name="MetricAggregation" type="MetricAggregation" minOccurs="1" maxOccurs="5" />
    </xs:sequence>
    <xs:attribute name="resourceId" type="xs:string" use="required" />  
  </xs:complexType>
    
  <xs:complexType name="LogsProvider">
    <xs:attribute name="guid" type="guidType" use="required">
      <xs:annotation>
        <xs:documentation>
            The provider's GUID
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType> 
    
  <xs:complexType name="Logs">
    <xs:complexContent>
      <xs:extension base="LogsBase">
          <xs:sequence>
              <xs:element name="Provider" type="LogsProvider" minOccurs="0" maxOccurs="1"/>
          </xs:sequence>
          <xs:attributeGroup ref="LogLevel" />
      </xs:extension>
    </xs:complexContent>  
  </xs:complexType>  
    
  <xs:complexType name="DiagnosticMonitorConfiguration">
    <xs:all>
      <xs:element name="Metrics" type="Metrics" minOccurs="0">
        <xs:annotation>
            <xs:documentation>
                Should be used by the portal only. Creates 2 new counters tables.
            </xs:documentation>
        </xs:annotation>      
      </xs:element>  
      <xs:element name="DiagnosticInfrastructureLogs" type="DiagnosticInfrastructureLogs" minOccurs="0">
        <xs:annotation>
          <xs:documentation>
            Configures the logs generated by the underlying diagnostics infrastructure. The diagnostic infrastructure logs are useful for troubleshooting the diagnostics system itself.
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="Directories" type="Directories" minOccurs="0">
        <xs:annotation>
          <xs:documentation>
            Describes the configuration of a directory to which file-based logs are written.
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="PerformanceCounters" type="PerformanceCounters" minOccurs="0">
        <xs:annotation>
          <xs:documentation>
            Configures performance counter collection.
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="WindowsEventLog" type="WindowsEventLog" minOccurs="0">
        <xs:annotation>
          <xs:documentation>
            Configures Windows event log collection.
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="EtwProviders" type="EtwProviders" minOccurs="0">
        <xs:annotation>
          <xs:documentation>
            Configures ETW event collection.
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="CrashDumps" type="CrashDumps" minOccurs="0">
        <xs:annotation>
          <xs:documentation>
            Configures crashdump collection.
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="Logs" type="Logs" minOccurs="0">
        <xs:annotation>
          <xs:documentation>
            Configures generic diagnostics event trace listener.
          </xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:all>

    <xs:attribute name="overallQuotaInMB" type="xs:unsignedInt" use="optional" default="5120">
      <xs:annotation>
        <xs:documentation>
          The total amount of file system storage allocated for all logging buffers.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="useProxyServer" type="xs:boolean" use="optional" default="true">
      <xs:annotation>
        <xs:documentation>
          Force the Monitoring Agent to use the specified IE proxy server if specified.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:element name="PublicConfig">
    <xs:complexType>
      <xs:all>
        <xs:element name="WadCfg">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="DiagnosticMonitorConfiguration" type="DiagnosticMonitorConfiguration" minOccurs="1" maxOccurs="1" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="LocalResourceDirectory" minOccurs="0" maxOccurs="1"  type="DirectoryAbsolute" />
        <xs:element name="StorageAccount" minOccurs="0" maxOccurs="1" type="xs:string" />
      </xs:all>
    </xs:complexType>
  </xs:element>
</xs:schema>