Retrieving current version in ARM template for secret
I got this secret named "StorageConnectionString" that gets inserted in my Key Vault from ARM:
{
"type": "Microsoft.KeyVault/vaults/secrets",
"name": "[concat(variables('keyVaultName-v'),'/','StorageConnectionString')]",
"apiVersion": "2018-02-14",
"properties": {
"contentType": "text/plain",
"value": "OmittedStorageConntionString"
},
"dependsOn": [
"[resourceId('Microsoft.KeyVault/vaults', variables('keyVaultName-v'))]"
]
}
Is there any way that I can reference and get the url of current version (or just version id) of the inserted secret, from ARM? I want to reference it from an environment variable like mentioned here: https://azure.microsoft.com/en-us/blog/simplifying-security-for-serverless-and-web-apps-with-azure-functions-and-app-service/ under the section "Sourcing Application Settings from Key Vault". I want to set an environment setting @Microsoft.KeyVault(SecretUri=secret_uri_with_version)
in my Azure Function.
If this isnt possible, is there another way to set the connectionstring?


add a comment |
I got this secret named "StorageConnectionString" that gets inserted in my Key Vault from ARM:
{
"type": "Microsoft.KeyVault/vaults/secrets",
"name": "[concat(variables('keyVaultName-v'),'/','StorageConnectionString')]",
"apiVersion": "2018-02-14",
"properties": {
"contentType": "text/plain",
"value": "OmittedStorageConntionString"
},
"dependsOn": [
"[resourceId('Microsoft.KeyVault/vaults', variables('keyVaultName-v'))]"
]
}
Is there any way that I can reference and get the url of current version (or just version id) of the inserted secret, from ARM? I want to reference it from an environment variable like mentioned here: https://azure.microsoft.com/en-us/blog/simplifying-security-for-serverless-and-web-apps-with-azure-functions-and-app-service/ under the section "Sourcing Application Settings from Key Vault". I want to set an environment setting @Microsoft.KeyVault(SecretUri=secret_uri_with_version)
in my Azure Function.
If this isnt possible, is there another way to set the connectionstring?


add a comment |
I got this secret named "StorageConnectionString" that gets inserted in my Key Vault from ARM:
{
"type": "Microsoft.KeyVault/vaults/secrets",
"name": "[concat(variables('keyVaultName-v'),'/','StorageConnectionString')]",
"apiVersion": "2018-02-14",
"properties": {
"contentType": "text/plain",
"value": "OmittedStorageConntionString"
},
"dependsOn": [
"[resourceId('Microsoft.KeyVault/vaults', variables('keyVaultName-v'))]"
]
}
Is there any way that I can reference and get the url of current version (or just version id) of the inserted secret, from ARM? I want to reference it from an environment variable like mentioned here: https://azure.microsoft.com/en-us/blog/simplifying-security-for-serverless-and-web-apps-with-azure-functions-and-app-service/ under the section "Sourcing Application Settings from Key Vault". I want to set an environment setting @Microsoft.KeyVault(SecretUri=secret_uri_with_version)
in my Azure Function.
If this isnt possible, is there another way to set the connectionstring?


I got this secret named "StorageConnectionString" that gets inserted in my Key Vault from ARM:
{
"type": "Microsoft.KeyVault/vaults/secrets",
"name": "[concat(variables('keyVaultName-v'),'/','StorageConnectionString')]",
"apiVersion": "2018-02-14",
"properties": {
"contentType": "text/plain",
"value": "OmittedStorageConntionString"
},
"dependsOn": [
"[resourceId('Microsoft.KeyVault/vaults', variables('keyVaultName-v'))]"
]
}
Is there any way that I can reference and get the url of current version (or just version id) of the inserted secret, from ARM? I want to reference it from an environment variable like mentioned here: https://azure.microsoft.com/en-us/blog/simplifying-security-for-serverless-and-web-apps-with-azure-functions-and-app-service/ under the section "Sourcing Application Settings from Key Vault". I want to set an environment setting @Microsoft.KeyVault(SecretUri=secret_uri_with_version)
in my Azure Function.
If this isnt possible, is there another way to set the connectionstring?




asked Jan 2 at 21:02
mslotmslot
1,86762342
1,86762342
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The question was my last resort, and just after I posted this, I found the answer here: https://docs.microsoft.com/en-us/azure/app-service/app-service-key-vault-references#reference-syntax (in the documentation) "[concat('@Microsoft.KeyVault(SecretUri=', reference(variables('storageConnectionStringResourceId')).secretUriWithVersion, ')')]"
.
EDIT
By following the i mentioned before, you can in fact reference the secret in the ARM template and get the url to the secret with the version included.
Create a secret:
{
"type": "Microsoft.KeyVault/vaults/secrets",
"name": "[concat(variables('keyVaultName-v'),'/', variables('queueStorageConnectionStringSecretName-v'))]",
"apiVersion": "2018-02-14",
"properties": {
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('queueStorageName-v'), ';AccountKey=', listKeys(variables('storageAccountResourceId'),'2015-05-01-preview').key1)]"
}
And then you can reference it in your functions app
{
"name": "StorageQueueConnectionString",
"value": "[concat('@Microsoft.KeyVault(SecretUri=', reference(variables('queueStorageConnectionStringSecretNameResourceId-v')).secretUriWithVersion, ')')]"
}
Then, in your function, you can reference StorageQueueConnectionString
in a binding
[Queue("queueName", Connection ="StorageQueueConnectionString")]
ICollector<string> outputQueueItem
In this way, you dont have to reference the connectionstring in environment variables (or code), making your app a bit more secure. This example requires a system assigned (or user assigned) identity between the functions app and the vault. I am currently trying vault out, and I have made some code that can be found here: https://github.com/mslot/Microservices. The code is not beautiful! I am trying a lot of things out related to key vault and bindings between different Azure entities.
how does what you write here follow from what you linked?
– 4c74356b41
Jan 2 at 21:18
I am currently trying this out and will link to an example on github shortly.
– mslot
Jan 2 at 21:40
@4c74356b41 I have added a small pseudo example.
– mslot
Jan 2 at 23:55
add a comment |
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54013148%2fretrieving-current-version-in-arm-template-for-secret%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The question was my last resort, and just after I posted this, I found the answer here: https://docs.microsoft.com/en-us/azure/app-service/app-service-key-vault-references#reference-syntax (in the documentation) "[concat('@Microsoft.KeyVault(SecretUri=', reference(variables('storageConnectionStringResourceId')).secretUriWithVersion, ')')]"
.
EDIT
By following the i mentioned before, you can in fact reference the secret in the ARM template and get the url to the secret with the version included.
Create a secret:
{
"type": "Microsoft.KeyVault/vaults/secrets",
"name": "[concat(variables('keyVaultName-v'),'/', variables('queueStorageConnectionStringSecretName-v'))]",
"apiVersion": "2018-02-14",
"properties": {
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('queueStorageName-v'), ';AccountKey=', listKeys(variables('storageAccountResourceId'),'2015-05-01-preview').key1)]"
}
And then you can reference it in your functions app
{
"name": "StorageQueueConnectionString",
"value": "[concat('@Microsoft.KeyVault(SecretUri=', reference(variables('queueStorageConnectionStringSecretNameResourceId-v')).secretUriWithVersion, ')')]"
}
Then, in your function, you can reference StorageQueueConnectionString
in a binding
[Queue("queueName", Connection ="StorageQueueConnectionString")]
ICollector<string> outputQueueItem
In this way, you dont have to reference the connectionstring in environment variables (or code), making your app a bit more secure. This example requires a system assigned (or user assigned) identity between the functions app and the vault. I am currently trying vault out, and I have made some code that can be found here: https://github.com/mslot/Microservices. The code is not beautiful! I am trying a lot of things out related to key vault and bindings between different Azure entities.
how does what you write here follow from what you linked?
– 4c74356b41
Jan 2 at 21:18
I am currently trying this out and will link to an example on github shortly.
– mslot
Jan 2 at 21:40
@4c74356b41 I have added a small pseudo example.
– mslot
Jan 2 at 23:55
add a comment |
The question was my last resort, and just after I posted this, I found the answer here: https://docs.microsoft.com/en-us/azure/app-service/app-service-key-vault-references#reference-syntax (in the documentation) "[concat('@Microsoft.KeyVault(SecretUri=', reference(variables('storageConnectionStringResourceId')).secretUriWithVersion, ')')]"
.
EDIT
By following the i mentioned before, you can in fact reference the secret in the ARM template and get the url to the secret with the version included.
Create a secret:
{
"type": "Microsoft.KeyVault/vaults/secrets",
"name": "[concat(variables('keyVaultName-v'),'/', variables('queueStorageConnectionStringSecretName-v'))]",
"apiVersion": "2018-02-14",
"properties": {
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('queueStorageName-v'), ';AccountKey=', listKeys(variables('storageAccountResourceId'),'2015-05-01-preview').key1)]"
}
And then you can reference it in your functions app
{
"name": "StorageQueueConnectionString",
"value": "[concat('@Microsoft.KeyVault(SecretUri=', reference(variables('queueStorageConnectionStringSecretNameResourceId-v')).secretUriWithVersion, ')')]"
}
Then, in your function, you can reference StorageQueueConnectionString
in a binding
[Queue("queueName", Connection ="StorageQueueConnectionString")]
ICollector<string> outputQueueItem
In this way, you dont have to reference the connectionstring in environment variables (or code), making your app a bit more secure. This example requires a system assigned (or user assigned) identity between the functions app and the vault. I am currently trying vault out, and I have made some code that can be found here: https://github.com/mslot/Microservices. The code is not beautiful! I am trying a lot of things out related to key vault and bindings between different Azure entities.
how does what you write here follow from what you linked?
– 4c74356b41
Jan 2 at 21:18
I am currently trying this out and will link to an example on github shortly.
– mslot
Jan 2 at 21:40
@4c74356b41 I have added a small pseudo example.
– mslot
Jan 2 at 23:55
add a comment |
The question was my last resort, and just after I posted this, I found the answer here: https://docs.microsoft.com/en-us/azure/app-service/app-service-key-vault-references#reference-syntax (in the documentation) "[concat('@Microsoft.KeyVault(SecretUri=', reference(variables('storageConnectionStringResourceId')).secretUriWithVersion, ')')]"
.
EDIT
By following the i mentioned before, you can in fact reference the secret in the ARM template and get the url to the secret with the version included.
Create a secret:
{
"type": "Microsoft.KeyVault/vaults/secrets",
"name": "[concat(variables('keyVaultName-v'),'/', variables('queueStorageConnectionStringSecretName-v'))]",
"apiVersion": "2018-02-14",
"properties": {
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('queueStorageName-v'), ';AccountKey=', listKeys(variables('storageAccountResourceId'),'2015-05-01-preview').key1)]"
}
And then you can reference it in your functions app
{
"name": "StorageQueueConnectionString",
"value": "[concat('@Microsoft.KeyVault(SecretUri=', reference(variables('queueStorageConnectionStringSecretNameResourceId-v')).secretUriWithVersion, ')')]"
}
Then, in your function, you can reference StorageQueueConnectionString
in a binding
[Queue("queueName", Connection ="StorageQueueConnectionString")]
ICollector<string> outputQueueItem
In this way, you dont have to reference the connectionstring in environment variables (or code), making your app a bit more secure. This example requires a system assigned (or user assigned) identity between the functions app and the vault. I am currently trying vault out, and I have made some code that can be found here: https://github.com/mslot/Microservices. The code is not beautiful! I am trying a lot of things out related to key vault and bindings between different Azure entities.
The question was my last resort, and just after I posted this, I found the answer here: https://docs.microsoft.com/en-us/azure/app-service/app-service-key-vault-references#reference-syntax (in the documentation) "[concat('@Microsoft.KeyVault(SecretUri=', reference(variables('storageConnectionStringResourceId')).secretUriWithVersion, ')')]"
.
EDIT
By following the i mentioned before, you can in fact reference the secret in the ARM template and get the url to the secret with the version included.
Create a secret:
{
"type": "Microsoft.KeyVault/vaults/secrets",
"name": "[concat(variables('keyVaultName-v'),'/', variables('queueStorageConnectionStringSecretName-v'))]",
"apiVersion": "2018-02-14",
"properties": {
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('queueStorageName-v'), ';AccountKey=', listKeys(variables('storageAccountResourceId'),'2015-05-01-preview').key1)]"
}
And then you can reference it in your functions app
{
"name": "StorageQueueConnectionString",
"value": "[concat('@Microsoft.KeyVault(SecretUri=', reference(variables('queueStorageConnectionStringSecretNameResourceId-v')).secretUriWithVersion, ')')]"
}
Then, in your function, you can reference StorageQueueConnectionString
in a binding
[Queue("queueName", Connection ="StorageQueueConnectionString")]
ICollector<string> outputQueueItem
In this way, you dont have to reference the connectionstring in environment variables (or code), making your app a bit more secure. This example requires a system assigned (or user assigned) identity between the functions app and the vault. I am currently trying vault out, and I have made some code that can be found here: https://github.com/mslot/Microservices. The code is not beautiful! I am trying a lot of things out related to key vault and bindings between different Azure entities.
edited Jan 2 at 23:54
answered Jan 2 at 21:10
mslotmslot
1,86762342
1,86762342
how does what you write here follow from what you linked?
– 4c74356b41
Jan 2 at 21:18
I am currently trying this out and will link to an example on github shortly.
– mslot
Jan 2 at 21:40
@4c74356b41 I have added a small pseudo example.
– mslot
Jan 2 at 23:55
add a comment |
how does what you write here follow from what you linked?
– 4c74356b41
Jan 2 at 21:18
I am currently trying this out and will link to an example on github shortly.
– mslot
Jan 2 at 21:40
@4c74356b41 I have added a small pseudo example.
– mslot
Jan 2 at 23:55
how does what you write here follow from what you linked?
– 4c74356b41
Jan 2 at 21:18
how does what you write here follow from what you linked?
– 4c74356b41
Jan 2 at 21:18
I am currently trying this out and will link to an example on github shortly.
– mslot
Jan 2 at 21:40
I am currently trying this out and will link to an example on github shortly.
– mslot
Jan 2 at 21:40
@4c74356b41 I have added a small pseudo example.
– mslot
Jan 2 at 23:55
@4c74356b41 I have added a small pseudo example.
– mslot
Jan 2 at 23:55
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54013148%2fretrieving-current-version-in-arm-template-for-secret%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown