Exemplo n.º 1
0
            /// <summary>
            /// Create iot hub
            /// </summary>
            /// <param name="manager"></param>
            /// <param name="resourceGroup"></param>
            /// <param name="name"></param>
            /// <param name="properties"></param>
            /// <param name="rule"></param>
            /// <param name="logger"></param>
            public IoTHubResource(IoTHubFactory manager,
                                  IResourceGroupResource resourceGroup, string name,
                                  IotHubProperties properties, ILogger logger,
                                  SharedAccessSignatureAuthorizationRule rule)
            {
                _resourceGroup = resourceGroup;
                Name           = name;

                _manager    = manager;
                _properties = properties;
                _logger     = logger;

                PrimaryConnectionString = ConnectionString.CreateServiceConnectionString(
                    properties.HostName, rule.KeyName, rule.PrimaryKey).ToString();
                SecondaryConnectionString = ConnectionString.CreateServiceConnectionString(
                    properties.HostName, rule.KeyName, rule.SecondaryKey).ToString();

                if (properties.EventHubEndpoints.TryGetValue("events", out var evtHub))
                {
                    EventHubConnectionString = ConnectionString.CreateEventHubConnectionString(
                        evtHub.Endpoint, rule.KeyName, rule.PrimaryKey).ToString();
                }
            }