Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
javaazureappconfig
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jalaluddin Shaikh
javaazureappconfig
Commits
fdc00389
Commit
fdc00389
authored
Mar 23, 2020
by
Jalaluddin Shaikh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Read/ Write Functionality from Azure to Client
parent
09eb3a63
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
6 deletions
+25
-6
pom.xml
pom.xml
+2
-1
JavaAzureAppConfigApplication.java
src/main/java/com/example/JavaAzureAppConfigApplication.java
+23
-5
No files found.
pom.xml
View file @
fdc00389
...
...
@@ -16,6 +16,7 @@
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
<maven.compiler.source>
1.8
</maven.compiler.source>
<maven.compiler.target>
1.8
</maven.compiler.target>
<azure-app-config.version>
1.1.0
</azure-app-config.version>
<log4j.version>
2.13.1
</log4j.version>
<lombok.version>
1.18.12
</lombok.version>
<junit.version>
4.13
</junit.version>
...
...
@@ -25,7 +26,7 @@
<dependency>
<groupId>
com.azure
</groupId>
<artifactId>
azure-data-appconfiguration
</artifactId>
<version>
1.1.0
</version>
<version>
${azure-app-config.version}
</version>
</dependency>
<dependency>
<groupId>
org.apache.logging.log4j
</groupId>
...
...
src/main/java/com/example/JavaAzureAppConfigApplication.java
View file @
fdc00389
...
...
@@ -10,21 +10,39 @@ import org.slf4j.LoggerFactory;
public
class
JavaAzureAppConfigApplication
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
JavaAzureAppConfigApplication
.
class
);
private
final
ConfigurationClient
configurationClient
;
private
final
SettingSelector
settingSelector
;
public
static
void
main
(
String
[]
args
)
{
try
{
LOGGER
.
info
(
"JavaAzureAppConfigApplication..."
);
String
app_configuration_connection_string
=
System
.
getenv
(
"APP_CONFIGURATION_CONNECTION_STRING"
);
ConfigurationClient
configurationClient
=
new
ConfigurationClientBuilder
().
connectionString
(
app_configuration_connection_string
).
buildClient
();
new
JavaAzureAppConfigApplication
().
azureAppConfiguration
();
}
private
void
azureAppConfiguration
()
{
try
{
LOGGER
.
info
(
"Read Single Value by key"
);
ConfigurationSetting
configurationSetting
=
configurationClient
.
getConfigurationSetting
(
"config.message"
,
null
);
LOGGER
.
info
(
"Message: {}"
,
configurationSetting
.
getValue
());
LOGGER
.
info
(
"Writing Single Value by key"
);
configurationSetting
=
configurationClient
.
setConfigurationSetting
(
"config.datasource"
,
null
,
"Data Source URL"
);
LOGGER
.
info
(
"Data Source URL From Application: {}"
,
configurationSetting
.
getValue
());
LOGGER
.
info
(
"Read All Values..."
);
configurationClient
.
listConfigurationSettings
(
new
SettingSelector
()).
forEach
(
property
->
LOGGER
.
info
(
"Message: {}"
,
property
.
getValue
()));
configurationClient
.
listConfigurationSettings
(
settingSelector
).
forEach
(
property
->
LOGGER
.
info
(
"Key: {} \t Value: {}"
,
property
.
getKey
(),
property
.
getValue
()));
LOGGER
.
info
(
"Remove Single Value by key"
);
configurationClient
.
deleteConfigurationSetting
(
"config.datasource"
,
null
);
LOGGER
.
info
(
"After Removing Key-Value Read All Values..."
);
configurationClient
.
listConfigurationSettings
(
settingSelector
).
forEach
(
property
->
LOGGER
.
info
(
"Key: {} \t Value: {}"
,
property
.
getKey
(),
property
.
getValue
()));
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
e
.
getMessage
(),
e
);
}
}
{
String
app_configuration_connection_string
=
System
.
getenv
(
"APP_CONFIGURATION_CONNECTION_STRING"
);
configurationClient
=
new
ConfigurationClientBuilder
().
connectionString
(
app_configuration_connection_string
).
buildClient
();
settingSelector
=
new
SettingSelector
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment