-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[app-configuration] Adding in sample code and readme #5091
Conversation
@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 |
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. |
c81ea00
to
a066803
Compare
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). |
a066803
to
a8563e5
Compare
* Removing the browser examples since we're not yet supporting browsers.
* Updating readme with links to the samples and instructions on how to build and test it for contributions * Removing troubleshooting section until we add in logging
* Add in a section for examples
const acceptDateTime = new Date(); | ||
const fields = ["etag"]; | ||
|
||
await client.listConfigurationSettings({ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
No description provided.