Giter VIP home page Giter VIP logo

digital-twins-samples-csharp's Introduction

page_type languages products name description
sample
csharp
azure
azure-digital-twins
Digital Twins Samples (ARCHIVED)
For the older version of Azure Digital Twins: This repo contains .NET Core samples that demonstrate how to use the Azure Digital Twins platform. Each folder contains a separate .NET Core app.

Digital Twins Samples (ARCHIVED)

License: MIT


NOTE (July 2020): A new version of the Azure Digital Twins service has been released, with new features and new implementation details. This sample repository corresponds to the previous set of documentation, which has now been archived. It no longer reflects the current Azure Digital Twins best practices and is no longer being maintained.

To view the latest information for the new service, visit the active Azure Digital Twins Documentation and its samples.


This repo contains .NET Core samples that demonstrate how to use the Azure Digital Twins platform. Each folder contains a separate .NET Core app.

See the README.md in each sub-folder for specific details about each app:

Get Started

  1. Install dotnet core.
  2. Clone the repo:
git clone https://github.com/Azure-Samples/digital-twins-samples-csharp.git
cd digital-twins-samples-csharp

The repo contains several standalone projects:

  • The Occupancy sample is suggested as a first example to gain familiarity with Digital Twins.
  • The Device Connectivity sample demonstrates how to connect a device to Digital Twins and submit sensory data.

For corresponding documentation, please see the project README's above.

Visual Studio Code

A workspace file containing all the apps is included for Visual Studio Code users.

Alternatively, each app can be opened individually.

Licensing and Use

Azure Digital Twins Samples are MIT Licensed.

See also

digital-twins-samples-csharp's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

digital-twins-samples-csharp's Issues

x-ms-flighting-udf-execution-manually-enabled no longer needed

Description

Connectivity sample still sends x-ms-flighting-udf-execution-manually-enabled.

Repro steps

Use connectivity sample.

Expected behavior

No need for x-ms-flighting-udf-execution-manually-enabled.

Actual behavior

x-ms-flighting-udf-execution-manually-enabled is sent.

Logs

   10/5/2018 2:13:45 PM> Sending message: {"SensorValue":"true"} Properties: { 'DigitalTwins-Telemetry': '1.0','DigitalTwins-SensorHardwareId': 'SAMPLE_SENSOR_MOTION','CreationTimeUtc': '2018-10-05T21:13:45.3363177Z','x-ms-client-request-id': '2d0a1d07-5065-43e2-9421-61ec3fedd7ad','x-ms-flighting-udf-execution-manually-enabled': 'true', }

Response Status: 403, Forbidden

Description

Hi, While running following command (dotnet run ProvisionSample), getting response status :-
Response Status: 403, Forbidden {"error":{"code":"403.600.000.001","message":"System error."}}

Repro steps

Please provide the steps required to reproduce the problem.

  1. dotnet run ProvisionSample

  2. authenticated with azure login.

  3. error --Response Status: 403, Forbidden {"error":{"code":"403.600.000.001","message":"System error."}}

Expected behavior

should be get connectionstring

BaseUrl in settings without a trailing dash breaks api calls

Description

baseUrl in settings without a trailing dash breaks api calls

Repro steps

see above

Expected behavior

It should work with or without

Actual behavior

It doesn't

Logs

If applicable, please provide any logs or output from the sample.

Known workarounds

Add a trailing /

Related information

  • Operating system
  • CoreCLR version (run dotnet --version)

Provisioning of IoT Hub resource not working in case of existence of free IoT Hub in subscription

Description

As provisionSample.yaml file does not contain size setting for IoT Hub resource, default value of XSmall (XS) size is used during POST request to /api/v1.0/resources endpoint, which means that underlying IoT Hub resource is being created in free tier. As there is limitation of one free IoT Hub per subscription, this provisioning ends with error in case there was free IoT Hub already deployed to subscription before.

Repro steps

Deploy free IoT Hub instances to Azure subscription and afterwards run Digital Twins provision Sample

Expected behavior

Add and discuss option to select size of IoT Hub within sample and quickstart docs

Known workarounds

Add size propety to ResourceDescription class + add size setting to provisionSample.yaml file in following way:

  • name: Quickstart Building
    type: Venue
    resources:
    • type: IoTHub
      size: M (available option XS, S, M, L, XL, XXL)
  • Operating system
    N/A
  • CoreCLR version (run dotnet --version)
    N/A

Consider using Microsoft.Azure.Services.AppAuthentication for S2S calls

Please review this article. There might be opportunity to simplify sample project and documentation.

https://docs.microsoft.com/en-us/azure/key-vault/service-to-service-authentication

This is how I modified sample to get it to run in the context of logged in user.

        private static async Task<HttpClient> SetupHttpClient(ILogger logger, AppSettings appSettings)
        {
            var httpClient = new HttpClient(new LoggingHttpHandler(logger))
            {
                BaseAddress = new Uri(appSettings.BaseUrl),
            };

            var tokenProvider = new AzureServiceTokenProvider();
            var accessToken = await tokenProvider.GetAccessTokenAsync("0b07f429-9f4b-4714-9392-cc5e8e80c8b0");

            //var accessToken = (await Authentication.GetToken(logger, appSettings));
            httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + accessToken);
            httpClient.DefaultRequestHeaders.Add("x-ms-flighting-udf-execution-manually-enabled", "true");
            return httpClient;
        }

@sup-s, you might be interested in this as well.

Occupancy and device connection sample seems too inclined towards room not being available

Description

I have both the data generator and the occupancy checker running. For the entire runtime of both, it never showed up as being good, it was always

"Name: Focus Room A1
Id: 9b8d36b1-5873-480b-bd8c-216245dbcac3
Value: Room is not available or air quality is poor"

Offline discussion in the bug bash room seemed to indicate that perhaps the range values were too sensitive and should be adjusted so people are more inclined to get a result in which the room is just right.

Repro steps

I ran through the steps documented here: https://review.docs.microsoft.com/en-us/azure/digital-twins/tutorial-facilities-udf?branch=pr-en-us-54424
(and the prerequisites)

Add caching of access token to occupancy-quickstart

Description

It would be useful not have to rerun devicelogin auth as often as is required currently.

Repro steps

Run any command (eg dotnet run GetAvailableAndFreshSpaces) more than once in short succession.

Expected behavior

Only the first should cause devicelogin

Actual behavior

Each call requires it

Occupancy Sample could use a few clarifications

Description

I'm on the following page: https://github.com/Azure-Samples/digital-twins-samples-csharp/blob/master/occupancy-quickstart/readme.md

The "Update appsettings.json using a text editor" should refer to it as appSettings.json to be consistent on casing.
The following commands have a couple of issue:

Run the app (and see usage)
dotnet restore
cd src
dotnet run

dotnet restore has to be run from within src, so the first two lines should be reversed in order. Also, the "dotnet run" doesn't actually run the app as would be implied by "Run the app", it just shows the usage.

Additionally, it would be helpful for the initial part of this sample to be linking to the tutorial that lets you create the Digital Twins instance.

Please register provisionSample.yaml as content to copy it to bin directory

Could not find a part of the path 'C:\Sources\2018-10-05-bugbash\digital-twins-samples-csharp\occupancy-quickstart\src\bin\Debug\netcoreapp2.1\actions\provisionSample.yaml'.

Exception: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Sources\2018-10-05-bugbash\digital-twins-samples-csharp\occupancy-quickstart\src\bin\Debug\netcoreapp2.1\actions\provisionSample.yaml'.
   at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
   at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
   at System.IO.StreamReader..ctor(String path)
   at Microsoft.Azure.DigitalTwins.Samples.Actions.ProvisionSample(HttpClient httpClient, ILogger logger) in C:\Sources\2018-10-05-bugbash\digital-twins-samples-csharp\occupancy-quickstart\src\actions\provisionSample.cs:line 19
   at Microsoft.Azure.DigitalTwins.Samples.Program.Main(String[] args) in C:\Sources\2018-10-05-bugbash\digital-twins-samples-csharp\occupancy-quickstart\src\program.cs:line 49

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.