{"id":17799,"date":"2022-10-27T04:29:01","date_gmt":"2022-10-26T22:59:01","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-bot-cloning-in-azure\/"},"modified":"2022-10-27T04:29:01","modified_gmt":"2022-10-26T22:59:01","slug":"solved-bot-cloning-in-azure","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-bot-cloning-in-azure\/","title":{"rendered":"[Solved] Bot Cloning in Azure"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-74019330\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"74019330\" data-parentid=\"73562993\" data-score=\"2\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<p>So it is possible to solve this programatically. I went about it using Powershell scripts, specifically Azure CLI and Azure Powershell. However, I believe that the standard is via Terraform (aka TF) or Pulumi and if I had to do this again I would probably use one of those IaaS tools. Especially since these tools do not depend on order of configuration (at least TF does not), whereas the Powershell scripting does.<\/p>\n<p>Regarding the scripting, you can configure a resource group, an application registration and its settings (service principal and app credential), and the azure bot service and its settings.<\/p>\n<p>I had to somewhat reverse engineer this process, so I personally would recommend starting with the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/learn.microsoft.com\/en-us\/powershell\/module\/az.botservice\/get-azbotservice?view=azps-8.3.0\">Get-AzBotService<\/a> command to see what you need to duplicate from your bot (note that you may prefer the Azure CLI version of this command: <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/learn.microsoft.com\/en-us\/cli\/azure\/bot?view=azure-cli-latest#az-bot-show\">az bot show<\/a>).<\/p>\n<p>I also recommend using the Azure CLI to set up the bot service as it offers more fine control than Azure Powershell.<\/p>\n<p>Note that I will just be using variable name holders for each field in the Powershell commands. I realize this might not result in the clearest explanation, but my use case had more configuration details than what I believe the average use case had and MS does have documentation on each field under each of the Powershell commands. However, if a future reader would like even more details, comment below and I&#8217;ll happily supplement whatever MS docs are not clear.<\/p>\n<p>You will need to start by <strong>logging into both Azure CLI and Azure Powershell<\/strong>. I recommend using these code blocks so you don&#8217;t always have the login tab open in your browser:<\/p>\n<pre><code>$loginStatus = Get-AzContext\nif ( -not ($loginStatus) ) {\n    Connect-AzAccount\n    $subscription_id = Get-AzSubscription\n    Set-AzContext -SubscriptionId ($subscription_id)\n}\n<\/code><\/pre>\n<p>and<\/p>\n<pre><code>$loginStatusAz = az account show\nif ( -not ($loginStatusAz) ) {\n    az login\n}\n<\/code><\/pre>\n<p>I first recommend <strong>creating the resource group<\/strong> for your bot:<br \/>\n<code>New-AzResourceGroup -Location $location -Name $resourceGroupName<\/code><\/p>\n<p>Next, I would <strong>create the application registration<\/strong> for your application:<\/p>\n<pre><code>$appInfo = New-AzAdApplication `\n    -DisplayName $registrationName `\n    -Web $webConfig`\n    -ReplyUrl $replyUrls `\n    -IdentifierUri $identifierUris `\n    -Api $api `\n    -SignInAudience $signInAudience\n<\/code><\/pre>\n<p><strong>One note here<\/strong> &#8211; make sure your configuration of the <code>-SignInAudience<\/code> flag results in your application being multi-tenant. I found that my use case had issues otherwise. Also, depending on how you configure this, you may need to use <code>Update-AzADApplication<\/code> after creating a basic application registration with <code>New-AzAdApplication<\/code>. So in my case I would create the application registration with just the <code>-DisplayName<\/code> and <code>-Web<\/code> flags configured and then update it with the rest of the information.<\/p>\n<p>You can configure other settings if you would like &#8211; I had to for my use case, but I won&#8217;t go into too much more detail here. If something more complicated is needed I would recommend using TF at this point, as it is easier to determine how to configure more complex settings of an application registration that way compared to using Powershell scripting.<\/p>\n<p><strong>Creating the service principal and application credentials<\/strong>:<\/p>\n<pre><code>New-AzAdServicePrincipal -ApplicationId $appInfo.AppId\n\n$secretInfo = New-AzADAppCredential -ObjectId $appInfo.Id\n<\/code><\/pre>\n<p><strong>Note:<\/strong> I would save the secret creds for future use.<\/p>\n<p>To <strong>create the bot<\/strong>:<\/p>\n<pre><code>az bot create `\n    --app-type $appType `\n    --appid $appInfo.AppId `\n    --name $botName `\n    --resource-group $resourceGroupName `\n    --endpoint $messagingEndpoint `\n    --sku $sku\n<\/code><\/pre>\n<p>To <strong>add channel configurations<\/strong> to the bot:<\/p>\n<pre><code>az bot msteams create `\n    --name $botName `\n    --resource-group $resourceGroupName\n<\/code><\/pre>\n<p>You may need a different command &#8211; this is specific to the MS teams channel, but the <code>az bot<\/code> command should have more documentation for it.<\/p>\n<p>To <strong>add authsetting<\/strong> to the bot:<\/p>\n<pre><code>az bot authsetting create `\n    --client-id $appInfo.AppId `\n    --client-secret $secretInfo.SecretText `\n    --name $botName `\n    --provider-scope-string $providerScopeString `\n    --resource-group $resourceGroupName `\n    --service $serviceName `\n    --setting-name $connectionName `\n    --parameters \"tenantId=$($tenantId)\" \"tokenExchangeUrl=$($tokenExchangeUrl)\"\n<\/code><\/pre>\n<p>You may need to change your parameters depeninding on what type of auth connection service you use &#8211; I was using oauth.<\/p>\n<p>That&#8217;s more or less it from a high level. Again, if more questions\/details are needed, happy to update, but I believe this is a really good starting point for anyone who needs to create\/duplicate a bot in Azure programatically.<\/p>\n<p>Here are the docs for the commands I used and some that may be useful:<\/p>\n<ul>\n<li><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/learn.microsoft.com\/en-us\/powershell\/module\/az.resources\/new-azresourcegroup?view=azps-8.3.0\">New-AzResourceGroup<\/a><\/li>\n<li><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/learn.microsoft.com\/en-us\/powershell\/module\/az.resources\/new-azadapplication?view=azps-8.3.0\">New-AzAdApplication<\/a><\/li>\n<li><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/learn.microsoft.com\/en-us\/powershell\/module\/az.resources\/update-azadapplication?view=azps-8.3.0\">Update-AzADApplication<\/a> (might be useful)<\/li>\n<li><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/learn.microsoft.com\/en-us\/powershell\/module\/az.resources\/new-azadserviceprincipal?view=azps-8.3.0\">New-AzAdServicePrincipal<\/a><\/li>\n<li><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/learn.microsoft.com\/en-us\/powershell\/module\/az.resources\/new-azadappcredential?view=azps-8.3.0\">New-AzADAppCredential<\/a><\/li>\n<li><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/learn.microsoft.com\/en-us\/cli\/azure\/bot?view=azure-cli-latest\">az bot<\/a><\/li>\n<\/ul>\n<\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\"><\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved Bot Cloning in Azure <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] So it is possible to solve this programatically. I went about it using Powershell scripts, specifically Azure CLI and Azure Powershell. However, I believe that the standard is via Terraform (aka TF) or Pulumi and if I had to do this again I would probably use one of those IaaS tools. Especially since these &#8230; <a title=\"[Solved] Bot Cloning in Azure\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-bot-cloning-in-azure\/\" aria-label=\"More on [Solved] Bot Cloning in Azure\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[1006,4392,4391,4393,4394],"class_list":["post-17799","post","type-post","status-publish","format-standard","hentry","category-solved","tag-azure","tag-azure-automation","tag-azure-bot-service","tag-azure-deployment","tag-azure-template"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Solved] Bot Cloning in Azure - JassWeb<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jassweb.com\/solved\/solved-bot-cloning-in-azure\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] Bot Cloning in Azure - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] So it is possible to solve this programatically. I went about it using Powershell scripts, specifically Azure CLI and Azure Powershell. However, I believe that the standard is via Terraform (aka TF) or Pulumi and if I had to do this again I would probably use one of those IaaS tools. Especially since these ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-bot-cloning-in-azure\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2022-10-26T22:59:01+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-bot-cloning-in-azure\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-bot-cloning-in-azure\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] Bot Cloning in Azure\",\"datePublished\":\"2022-10-26T22:59:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-bot-cloning-in-azure\/\"},\"wordCount\":595,\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"keywords\":[\"azure\",\"azure-automation\",\"azure-bot-service\",\"azure-deployment\",\"azure-template\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-bot-cloning-in-azure\/\",\"url\":\"https:\/\/jassweb.com\/solved\/solved-bot-cloning-in-azure\/\",\"name\":\"[Solved] Bot Cloning in Azure - JassWeb\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#website\"},\"datePublished\":\"2022-10-26T22:59:01+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-bot-cloning-in-azure\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jassweb.com\/solved\/solved-bot-cloning-in-azure\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-bot-cloning-in-azure\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jassweb.com\/solved\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] Bot Cloning in Azure\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jassweb.com\/solved\/#website\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jassweb.com\/solved\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"contentUrl\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775193939\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775193939\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\/\/jassweb.com\"],\"url\":\"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] Bot Cloning in Azure - JassWeb","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jassweb.com\/solved\/solved-bot-cloning-in-azure\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] Bot Cloning in Azure - JassWeb","og_description":"[ad_1] So it is possible to solve this programatically. I went about it using Powershell scripts, specifically Azure CLI and Azure Powershell. However, I believe that the standard is via Terraform (aka TF) or Pulumi and if I had to do this again I would probably use one of those IaaS tools. Especially since these ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-bot-cloning-in-azure\/","og_site_name":"JassWeb","article_published_time":"2022-10-26T22:59:01+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-bot-cloning-in-azure\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-bot-cloning-in-azure\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] Bot Cloning in Azure","datePublished":"2022-10-26T22:59:01+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-bot-cloning-in-azure\/"},"wordCount":595,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["azure","azure-automation","azure-bot-service","azure-deployment","azure-template"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-bot-cloning-in-azure\/","url":"https:\/\/jassweb.com\/solved\/solved-bot-cloning-in-azure\/","name":"[Solved] Bot Cloning in Azure - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2022-10-26T22:59:01+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-bot-cloning-in-azure\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-bot-cloning-in-azure\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-bot-cloning-in-azure\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] Bot Cloning in Azure"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775193939","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775193939","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/17799","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=17799"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/17799\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=17799"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=17799"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=17799"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}