create a certificate

<java-install-dir>/bin/

keytool -genkey -alias <keystore-id>
-keystore <cert-store-dir>/<cert-file-name>.pfx -storepass <password>
-validity 3650 -keyalg RSA -keysize 2048 -storetype pkcs12
-dname "CN=Self Signed Certificate 20141118170652"

eg: keytool -genkey -alias javacer -keystore d:/java.pfx -storepass 123Aking -validity 3650 -keyalg RSA -keysize 2048 -storetype pkcs12
-dname "CN=Self Signed Certificate 20141118170652"

Convert the PFX file into JKS

<java-install-dir>/bin/keytool.exe -importkeystore
-srckeystore <cert-store-dir>/<cert-file-name>.pfx
-destkeystore <cert-store-dir>/<cert-file-name>.jks
-srcstoretype pkcs12 -deststoretype JKS

eg:keytool.exe -importkeystore -srckeystore d:/java.pfx
-destkeystore d:/javajks.jks
-srcstoretype pkcs12 -deststoretype JKS

to create cer file

<java-install-dir>/bin/keytool -export -alias <keystore-id>
-storetype pkcs12 -keystore <cert-store-dir>/<cert-file-name>.pfx
-storepass <password> -rfc -file <cert-store-dir>/<cert-file-name>.cer

eg: keytool -export -alias javacer
-storetype pkcs12 -keystore d:/java.pfx
-storepass 123Aking -rfc -file d:/javacer.cer

package common;
import java.net.URI;
import java.util.ArrayList; // Imports for Exceptions
import java.io.IOException;
import java.net.URISyntaxException;
import javax.xml.parsers.ParserConfigurationException;
import com.microsoft.windowsazure.exception.ServiceException;
import org.xml.sax.SAXException; // Imports for Azure App Service management configuration
import com.microsoft.windowsazure.Configuration;
import com.microsoft.windowsazure.management.configuration.ManagementConfiguration; // Service management imports for App Service Web Apps creation
import com.microsoft.windowsazure.management.websites.*;
import com.microsoft.windowsazure.management.websites.models.*; // Imports for authentication
import com.microsoft.windowsazure.core.utils.KeyStoreType; import com.microsoft.windowsazure.management.websites.models.WebSpaceNames; public class createazurevm { private static String uri = "https://management.core.windows.net/";
private static String subscriptionId = "****9";
private static String keyStoreLocation = "D:\\javajks.jks";
private static String keyStorePassword = "123Aking"; // Define web app parameter values.
private static String webAppName = "jamborjavacrate";
private static String domainName = ".azurewebsites.net";
private static String webSpaceName = WebSpaceNames.EASTASIAWEBSPACE;
private static String appServicePlanName = "jamborplan"; public static void main(String[] args)
throws IOException, URISyntaxException, ServiceException,
ParserConfigurationException, SAXException, Exception { // Create web app
createWebApp(); }
private static void createWebApp() throws Exception { // Specify configuration settings for the App Service management client.
Configuration config = ManagementConfiguration.configure(
new URI(uri),
subscriptionId,
keyStoreLocation, // Path to the JKS file
keyStorePassword, // Password for the JKS file
KeyStoreType.jks // Flag that you are using a JKS keystore
); // Create the App Service Web Apps management client to call Azure APIs
// and pass it the App Service management configuration object.
WebSiteManagementClient webAppManagementClient = WebSiteManagementService.create(config); // Create an App Service plan for the web app with the specified parameters.
WebHostingPlanCreateParameters appServicePlanParams = new WebHostingPlanCreateParameters();
appServicePlanParams.setName(appServicePlanName);
appServicePlanParams.setSKU(SkuOptions.Free);
webAppManagementClient.getWebHostingPlansOperations().create(webSpaceName, appServicePlanParams); // Set webspace parameters.
WebSiteCreateParameters.WebSpaceDetails webSpaceDetails = new WebSiteCreateParameters.WebSpaceDetails();
webSpaceDetails.setGeoRegion(GeoRegionNames.WESTUS);
webSpaceDetails.setPlan(WebSpacePlanNames.VIRTUALDEDICATEDPLAN);
webSpaceDetails.setName(webSpaceName); // Set web app parameters.
// Note that the server farm name takes the Azure App Service plan name.
WebSiteCreateParameters webAppCreateParameters = new WebSiteCreateParameters();
webAppCreateParameters.setName(webAppName);
webAppCreateParameters.setServerFarm(appServicePlanName);
webAppCreateParameters.setWebSpace(webSpaceDetails); // Set usage metrics attributes.
WebSiteGetUsageMetricsResponse.UsageMetric usageMetric = new WebSiteGetUsageMetricsResponse.UsageMetric();
usageMetric.setSiteMode(WebSiteMode.Basic);
usageMetric.setComputeMode(WebSiteComputeMode.Shared); // Define the web app object.
ArrayList<String> fullWebAppName = new ArrayList<String>();
fullWebAppName.add(webAppName + domainName);
WebSite webApp = new WebSite();
webApp.setHostNames(fullWebAppName); // Create the web app.
WebSiteCreateResponse webAppCreateResponse = webAppManagementClient.getWebSitesOperations().create(webSpaceName, webAppCreateParameters); // Output the HTTP status code of the response; 200 indicates the request succeeded; 4xx indicates failure.
System.out.println("----------");
System.out.println("Web app created - HTTP response " + webAppCreateResponse.getStatusCode() + "\n"); // Output the name of the web app that this application created.
String shinyNewWebAppName = webAppCreateResponse.getWebSite().getName();
System.out.println("----------\n");
System.out.println("Name of web app created: " + shinyNewWebAppName + "\n");
System.out.println("----------\n");
}
}

Java create azure web app的更多相关文章

  1. Azure Web App (一)发布你的Net Core Web 项目

    一,引言 今天我们看一下Azure上的一个服务-----Web 应用,我们都知道云计算的三大模式:Iaas(基础设施即服务),Paas(平台即服务),Saas(软件即服务). Iass,其实就是虚拟主 ...

  2. 如何用Azure Web App Services接入微信公众号

    注:本文提到的代码示例下载地址>如何用Azure Web App Services接入微信公众号 如何用Azure Web App Services接入微信公众号 简介 此示例演示如何创建Azu ...

  3. 远程调试 Azure Web App

    当我们将 Web App 部署在 Azure 上时,如果能够实现远程调试,将会极大的提高我们修复 bug 的效率.Visual Studio 一贯以功能强大.易用著称,当然可以实现基于 Azure 应 ...

  4. Windows Azure HandBook (7) 基于Azure Web App的企业官网改造

    <Windows Azure Platform 系列文章目录> 1.用户场景: C公司是全球大型跨国连锁餐厅,在世界上大约拥有3万间分店.其IT系统主要部署其海外数据中心,或者租用其他ID ...

  5. java.lang.IllegalStateException:Web app root system property already set to different value 错误原因及解决 Log4j

    Log4j是Apache的一个开放源代码项目,通过使用Log4j,我们可以控制日志信息输送的目的地是控制台.文件.GUI组件.甚至是套接口 服务器.NT的事件记录器.UNIX Syslog守护进程等: ...

  6. 004.Create a web app with ASP.NET Core MVC using Visual Studio on Windows --【在 windows上用VS创建mvc web app】

    Create a web app with ASP.NET Core MVC using Visual Studio on Windows 在 windows上用VS创建mvc web app 201 ...

  7. Windows Azure Web Site (18) Azure Web App设置MIME

    <Windows Azure Platform 系列文章目录> 在笔者之前的文章中,介绍了我们在使用Azure Web App,可以把静态资源保存到Azure Storage中: Wind ...

  8. VS 远程调试 Azure Web App

    如果能够远程调试部署在 Azure 上的 Web App,将会极大的提高我们修复 bug 的效率.Visual Studio 一贯以功能强大.好用著称,当然可以通吃基于 Azure 应用的创建.发布和 ...

  9. Azure Web App (二)使用部署槽切换部署环境

    一,引言 前天我们将到使用Azure的 Pass 服务 “Web App” 去部署我们的.NET Core Web项目,也同时有介绍到如何在VS中配置登陆中国区的Azure账号,今天接着讲,我们部署完 ...

随机推荐

  1. K12(在线学习的平台)

    项目:K12(在线学习的平台) 一.背景 目的是做一个在线的学习平台,提高学生的课程完成度 K12:大目标是要取代线下班 - 录制专门的视频 - 导师的监管:如果没有主动和那个学生聊天,就扣钱 - 学 ...

  2. ubuntu 12.04的源更新

    apt-get install vim 安装vim vim /etc/apt/sources.list deb http://mirrors.163.com/ubuntu/ precise main ...

  3. wordpress Bloginfo()函数

    bloinfo($show); ‘name‘ – 显示在 设置 > 常规 中设置的“站点标题”. 该数据是从 wp_options 这个数据表中检索到的 "blogname" ...

  4. C++虚函数与纯虚函数用法与区别(转载)

    1. 虚函数和纯虚函数可以定义在同一个类(class)中,含有纯虚函数的类被称为抽象类(abstract class),而只含有虚函数的类(class)不能被称为抽象类(abstract class) ...

  5. HDU ACM Fibonacci

    Problem Description Fibonacci numbers are well-known as follow: Now given an integer N, please find ...

  6. 本博文将一步步带领你实现抽屉官网的各种功能:包括登陆、注册、发送邮箱验证码、登陆验证码、页面登陆验证、发布文章、上传图片、form验证、点赞、评论、文章分页处理以及基于tronado的后端和ajax的前端数据处理。

    本博文将一步步带领你实现抽屉官网的各种功能:包括登陆.注册.发送邮箱验证码.登陆验证码.页面登陆验证.发布文章.上传图片.form验证.点赞.评论.文章分页处理以及基于tronado的后端和ajax的 ...

  7. Mesh Filter & Mesh Render

    [Mesh Filter] The Mesh Filter takes a mesh from your assets and passes it to the Mesh Renderer for r ...

  8. OpenGL顶点缓冲区对象

    [OpenGL顶点缓冲区对象] 显示列表可以快速简单地优化立即模式(glBegin/glEnd)的代码.在最坏的情况下,显示列表的命令被预编译存到命令缓冲区中,然后发送给图形硬件.在最好的情况下,是编 ...

  9. java简单的测试方法执行了多少时间

    (1)以毫秒为单位的 long startTime = System.currentTimeMillis(); // 获取开始时间 // doThing(); // 测试的代码段 long endTi ...

  10. opencv3读取视频并保存为图片

    #include <iostream> #include <vector> #include <opencv2/opencv.hpp> using namespac ...