Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[app-configuration] Adding in sample code and readme #5091

Merged
merged 15 commits into from
Sep 12, 2019

Conversation

richardpark-msft
Copy link
Member

No description provided.

@richardpark-msft
Copy link
Member Author

@chradek , @ramya-rao-a - do we have a preference for samples? We have some that seem to live as tests and some that are standalone files.

These samples have been written so (hopefully) you can just copy and paste a single test into a project, so long as you import @azure/app-configuration

@chradek
Copy link
Contributor

chradek commented Sep 10, 2019

Is this PR to add samples for users to reference, or tests for some sample scenarios?

If the former, you can take a look at event-hubs for an example of what we do.

We should have a README in the samples folder that explains how to use any of the samples we commit. We then have sample files for various scenarios. You might be able to make these from some of the live tests, or look at what other language SDKs included with their samples.

@richardpark-msft
Copy link
Member Author

Okay, I found a mid-way solution that I think is nice.

I separated out the individual samples that I've got into two separate files (helloWorld.ts and helloWorldWithLabels.ts). Those files are tied together with an index.ts in the same folder which I then use and run within the tests.

So the samples are part of the main build/test loop (which was my actual goal).

@richardpark-msft richardpark-msft added the App Configuration Azure.ApplicationModel.Configuration label Sep 11, 2019
@richardpark-msft richardpark-msft changed the title [@azure/app-configuration] Adding in sample code [app-configuration] Adding in sample code Sep 11, 2019
@richardpark-msft richardpark-msft changed the title [app-configuration] Adding in sample code [app-configuration] Adding in sample code and readme Sep 11, 2019
const acceptDateTime = new Date();
const fields = ["etag"];

await client.listConfigurationSettings({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're using await, you can rewrite this as

const result = await client.listConfigurationSettings({
  label,
  key,
  acceptedDateTime,
  fields
});

console.log("The result is:", result);

You should also give an explanation of what some of the fields are...just looking at it I'm not sure what acceptDateTime is doing, or what specifying fields will do either.

Nit: I don't think top-level await exists yet, you'd need to use await inside of an async function.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I modified it to e a simpler API that basically does the same thing. The listConfigurationSetting() api is a bit more complex and could use a better sample which I can add in another PR.

* Fixed an issue where I wasn't awaiting on the result of the clean, causing the samples to be flaky when they ran
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
App Configuration Azure.ApplicationModel.Configuration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants